Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Customizing the Look of Your Shop / Templates, Stylesheets, Page Layout / Add code to the <body> tag of just one EZ page?

Add code to the <body> tag of just one EZ page?

Locked

Started by bhensarl on 10 Apr 2010, 7:37 AM · Views: 1,928

Results 1 to 14 of 14
This thread is locked. New replies are disabled.
10 Apr 2010, 7:37 AM
#1
bhensarl avatar

bhensarl

New Zenner

Join Date:
Feb 2010
Posts:
67
Plugin Contributions:
0

Post #1 by bhensarl

Hello,
I need to add ```
onload="initialize()"

Brian
10 Apr 2010, 9:19 AM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Post #2 by kuroi

In the docs folder that comes bundled with Zen Cart when you download it is a file about javascript. There's an explanation in there as to how to load javascript, or as you're asking, run it when the page loads.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

11 Apr 2010, 1:47 AM
#3
bhensarl avatar

bhensarl

New Zenner

Join Date:
Feb 2010
Posts:
67
Plugin Contributions:
0

Post #3 by bhensarl

Kuroi,
I think I've found the file you're talking about (read_me_jscript.html), but I still can't figure out how to alter the <body> tag because it seems to be only referring to working with javascript. Can you point me in the right direction? Thanks for the help.
Brian

11 Apr 2010, 8:35 AM
#4
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Post #4 by kuroi

Sorry, my bad. I should have directed you to the file that describes specifically how to add to the body onload attribute. That files in the same place as the one you found but called read_me_onload.html.

The idea that you should let go of, is that you add to the onload tag. That file will show you where and how to tell Zen Cart what you want added, and then Zen Cart will automatically do the adding for you on a page or site-wide basis depending upon which set of instructions you followed.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

11 Apr 2010, 6:12 PM
#5
bhensarl avatar

bhensarl

New Zenner

Join Date:
Feb 2010
Posts:
67
Plugin Contributions:
0

Post #5 by bhensarl

All right, perfect. Now I understand how to make it happen. Thanks for the help!
Now, my final question: what is the correct format for naming EZ pages folders in the modules/pages directory? The page I'd like to add to is ez page ID #13. I've tried naming the folder page_13 and that doesn't work. I'm assuming that I must have the wrong format for the folder names.
Thanks for your help thus far!
Brian

11 Apr 2010, 7:16 PM
#6
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Post #6 by kuroi

I'm sorry but the question doesn't make sense to me. EZ-Pages are stored as block of HTML in the database, i.e. they don't have folders.

Might you be confusing them with define pages, which are "real" pages built using PHP?

Or are you using EZ-Pages to create links to something that would reside in a folder?

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

11 Apr 2010, 9:13 PM
#7
bhensarl avatar

bhensarl

New Zenner

Join Date:
Feb 2010
Posts:
67
Plugin Contributions:
0

Post #7 by bhensarl

Sorry about that, I just didn't understand the way that the system works! What I'm trying to do is add the onload function to the body tag to one of my EZ-pages. Is that possible, or can you only add it PHP coded pages?

11 Apr 2010, 11:42 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #8 by drbyte

You can't target it to just one EZ-page specifically without writing custom code to accomplish that.

What exactly does this "initialize()" function call actually "do"? (Ya, I know it runs the "initialize()" function, which would logically start up some sort of javascript you've got on the page: what exactly is THAT doing? and why? )

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 Apr 2010, 12:19 AM
#9
bhensarl avatar

bhensarl

New Zenner

Join Date:
Feb 2010
Posts:
67
Plugin Contributions:
0

Post #9 by bhensarl

It starts up my google maps javascript. Is there a way to just insert the javascript into the ezpage instead of loading in the body tag? Here's what I actually want to put in: onunload="GUnload()"

12 Apr 2010, 12:34 AM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #10 by drbyte

So you're saying you don't really want an "onload" event at all?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 Apr 2010, 12:40 AM
#11
bhensarl avatar

bhensarl

New Zenner

Join Date:
Feb 2010
Posts:
67
Plugin Contributions:
0

Post #11 by bhensarl

Nope, sorry about that, I really want an "onunload" event. I know very little about javascript, so I apologize for my ignorance of the difference. Is there a way to put that into the body of the ez page?

12 Apr 2010, 12:59 AM
#12
bhensarl avatar

bhensarl

New Zenner

Join Date:
Feb 2010
Posts:
67
Plugin Contributions:
0

Post #12 by bhensarl

Nope, sorry about that. I'm looking for the "onunload" event. I know very little about javascript. Is there a way to incorporate that event into the ez page? Thanks.
Brian

12 Apr 2010, 1:16 AM
#13
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #13 by drbyte

You'll have to hack the PHP in tpl_main_page.php from this:```

<body id="<?php echo $body_id . 'Body'; ?>"<?php if($zv_onload !='') echo ' onload="'.$zv_onload.'"'; ?>> ```to this:``` <body id="<?php echo $body_id . 'Body'; ?>"<?php if($zv_onload !='') echo ' onload="'.$zv_onload.'"'; ?>[B]<?php if ($current_page_base == 'page' && $_GET['id'] == '29') echo ' onunload="GUnload()"'; ?>[/B]> ``` ... where '29' is the number assigned to the ez-page you're using.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

12 Apr 2010, 2:40 AM
#14
bhensarl avatar

bhensarl

New Zenner

Join Date:
Feb 2010
Posts:
67
Plugin Contributions:
0

Post #14 by bhensarl

Thanks so much, DrByte! I really appreciate it! Works like a charm.
Brian