Sunday 21 November 2010 5:31:59 pm
@Carlos: Thanks, that did it. Here's what I did (for the benefit of others). My problem was that the js - the one with the key in it - link in ezgmaplocation was causing problems with other js on the page. Manually moving it around confirmed that moving it into the page head fixes the problem. But of course changing a line in one of the pagelayout templates to suit an extension is not good practice. Initially I tried using the merge array function (@Gaetano: this is what I was talking about) http://doc.ez.no/doc/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/Arrays/merge with no luck. So here's what worked: I added this to the ezgmaplocation.tpl (override, of course) {def $mapkey=ezini('SiteSettings','GMapsKey')}
{def $jslinkstart='<script src="http://maps.google.com/maps?file=api&v=2&key='}
{def $jslinkend='" type="text/javascript"></script>'}
{def $googlemapslink=concat($jslinkstart,$mapkey,$jslinkend)}
{ezpagedata_set('script_list', array( $googlemapslink ))}
Then I added this to the beginning of page_head_script.tpl {if and( is_set( $pagedata.persistent_variable.script_list ), $pagedata.persistent_variable.script_list|count() )}
{foreach $pagedata.persistent_variable.script_list as $extra_script}
{$extra_script}
{/foreach}
There are two drawbacks I can see with this. One is that a future change to page_head_script.tpl could cause problems (ie the overridden version wouldn't reflect the changes). and two, if one were to use this method across a few extensions they would all become interdependent - breaking or removing one would break the rest. See this page for a bit more info. http://share.ez.no/forums/developer/smart-loading-of-javascript
Paul Bolger
|