Page 1 of 1

[SOLVED] Different BODY ONLOAD tags on different pages

Posted: Sat Oct 04, 2008 9:24 am
by finster
Hello all,

I'm trying to show a Google Map on one of my pages, like in this example http://code.google.com/apis/maps/documentation/examples/map-simple.html.

So far I've: -
  • Put the javascript into the META section of my "location" page, wrapped in {literal}s. - works OK.
  • Created a Global Content Block that contains the "map_canvas" DIV. - works OK.
My issue is how I add   

Code: Select all

</__body onload="initialize()" onunload="GUnload()">
to my "location" page but none of the other pages (as they don't have the javascript function on them). So far I have two templates, one with the plain BODY and one with the extra function call but I'd prefer to use just one template if possible.

Has anybody got any ideas?

Thanks...

Re: Different BODY ONLOAD tags on different pages

Posted: Sat Oct 04, 2008 10:52 am
by nhaack
Have you tried something like:

Code: Select all

</__body {content block="html_body_extension" oneline="true"}>
in your template? This way you get an extra field in your page editing dialog in which you can fill your

Code: Select all

onload="initialize()" onunload="GUnload()"
Works for me :)

Best
Nils

[SOLVED] Different BODY ONLOAD tags on different pages

Posted: Sat Oct 04, 2008 11:39 am
by finster
Brilliant, thanks. Just what I was after.

Hadn't heard of the "content block" before - I'll have to read up on it!

Works perfectly - thanks again.

Re: Different BODY ONLOAD tags on different pages

Posted: Tue Oct 14, 2008 2:59 pm
by jack4ya
Good for you!
Add [SOLVED] to you topic title then, please.

Re: Different BODY ONLOAD tags on different pages

Posted: Tue Oct 14, 2008 3:19 pm
by viebig
also you can skip global content blocks using something like:

Code: Select all

</__body{if $page_alias=='maps'} onload="initialize()" onunload="GUnload()"{/if}>
just an addictional way to do that.

Re: Different BODY ONLOAD tags on different pages

Posted: Tue Oct 14, 2008 5:28 pm
by finster
jack4ya wrote: Good for you!
Add [SOLVED] to you topic title then, please.
Sorry, thought I had done but it was just the title of a post that I'd changed, not the topic.

Thanks again all...