Hi all,
I have changed my piwigo theme to show the openstreet map from the category page on the picture pages as well. That works great except when showing the gpx file as picture (see http://www.feuster.com/piwigo/picture?/ … ace_center).
Root cause is that I include both osm-gpx.tpl and osm-map.tpl on the same page and so
<script src="/piwigo/plugins/piwigo-openstreetmap/leaflet/leaflet.js"></script>
gets added twice into the <head> section.
Is there any way to avoid that e.g. using some clever smarty feature? So far I haven't been able to come up with something helpful...
Thanks in advance,
Thomas
Offline
Reply to self and for documentation :-)
In an event handler for 'loc_end_picture' I now call the following:
function cleanup_html_head()
{
global $template;
// the variable in $template we're looking for is "html_head_elements"
// and its an array with one entry for each *.tpl that had a {html_head} section
if ( count($template->html_head_elements) )
{
// combine array elements into one AND split @ newline AND create a unique array
$template->html_head_elements = array_unique( explode( "\n", implode( "\n", $template->html_head_elements ) ) );
}
}
Seems to work fine :-)
Offline
Hello
Thx for sharing We have a github repo ; I notify rvelices
Offline
Apparently this plug-in does not use the combine script feature that allows any number of plug-ins to load a script exactly once.
The html head was not intended to load external scripts or css
Offline
Well, tell that to the developer of the piwigo-openstreetmap plugin :-)
As for including my fix in the general code: Thought about it as well BUT
- doesn't seem to be a common problem
- might have a performance hit since its done for all and an pages
I'd rather add it to the page where all the helpful code snippets are collected...
Offline