collective / collective.geolocationbehavior

Dexterity based behaviors for geotagging.
2 stars 2 forks source link

load bundles conditionally #11

Closed yurj closed 2 years ago

yurj commented 2 years ago

Hi! the leaflet bundle is quite heavy, is it possible to load it only on pages with the behavior enabled? I've found this reference on how to load it conditionally:

https://docs.plone.org/adapt-and-extend/theming/resourceregistry.html#bundles-request-api

but it is not clear to me where to insert the call to the api. Also, this tip can be useful:

https://play.pixelblaster.ro/blog/2017/02/23/test-for-an-interface-provided-by-object-in-plone-action-condition/

yurj commented 2 years ago

I've found that context.restrictedTraverse("@@plone_interface_info").provides('collective.geolocationbehavior.geolocation.IGeolocatable') is true if the object is geolocatable. This condition could be added to the bundle, but should be done in plone.formwidget.geolocation or maybe in the site profile.

yurj commented 2 years ago

Closing the issue, it is not strictly related to this addon.

yurj commented 2 years ago

https://github.com/collective/plone.formwidget.geolocation/pull/10 this pull has already added the feature but maybe the bundle must be disabled to make it work?