Zen Cart Logo
Forums / General Questions / Where to enter a javascript that goes in header?

Where to enter a javascript that goes in header?

Locked

Views: 1,000

Results 1 to 7 of 7
This thread is locked. New replies are disabled.
2 Nov 2008, 1:40 AM
#1
ckosloff avatar

ckosloff

Totally Zenned

Join Date:
Feb 2007
Location:
South Florida, USA
Posts:
1,375
Plugin Contributions:
0

Where to enter a javascript that goes in header?

I have been reading the wiki for javascript but maybe because of my lack of practice I still don't get clearly certain issues.
For example, I want to enter a js in a sidebox, it is pretty clear to me how to enter the <body> part, but not the <head> part, that is for a script that has two parts, of course.
Thanks.

2 Nov 2008, 2:16 AM
#2
pelasgos avatar

pelasgos

New Zenner

Join Date:
Dec 2006
Location:
Athens - Greece
Posts:
71
Plugin Contributions:
0

Re: Where to enter a javascript that goes in header?

Try html_header.php located in templates/custom_template/common.

This is where the headers (<head> </head>) are generated.

I don't know if that's the best way, but it worked for me. :smile:

George

2 Nov 2008, 5:47 AM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Where to enter a javascript that goes in header?

pelasgos:

Try html_header.php located in templates/custom_template/common.

This is where the headers (<head> </head>) are generated.

I don't know if that's the best way, but it worked for me. :smile:

George

That would be an ugly hack, and doesn't use the built-in autoplugin capability.

As the wiki article states, as well as the docs in the /docs/ folder of your Zen Cart files, you simply create a jscript_whatever.js file in the jscript folder of your template, and its contents will be automatically referenced in the <head> section of your pages. The article goes into detail of various alterations supported.

2 Nov 2008, 5:40 PM
#4
ckosloff avatar

ckosloff

Totally Zenned

Join Date:
Feb 2007
Location:
South Florida, USA
Posts:
1,375
Plugin Contributions:
0

Re: Where to enter a javascript that goes in header?

DrByte:

That would be an ugly hack, and doesn't use the built-in autoplugin capability.

As the wiki article states, as well as the docs in the /docs/ folder of your Zen Cart files, you simply create a jscript_whatever.js file in the jscript folder of your template, and its contents will be automatically referenced in the <head> section of your pages. The article goes into detail of various alterations supported.
AHA! To install the Comodo Corner of Trust Logo I used the ugly hack, it works, but...it might not be best practice.
The Comodo Sidebox mod. also uses the ugly hack, might have to rewrite that one too.
I will test the other alterations too.
Thanks for answer.
And thank too to pelasgos, I appreciate your good will.
When I say "ugly hack" I am not trying to be demeaning, just a quick way to reference it, I think that is DrByte's demeanor too.

3 Nov 2008, 7:04 PM
#5
pelasgos avatar

pelasgos

New Zenner

Join Date:
Dec 2006
Location:
Athens - Greece
Posts:
71
Plugin Contributions:
0

Re: Where to enter a javascript that goes in header?

An ungly hack is always an ungly hack.

It worked for me in the past, but now that DrByte showed the right way, I give it a try..

Thanks for pointing it DrByte, and thanks ckosloff for being the "triger" for that.

"...Each day I grow older, and learn something new..." (Solon the Athenian)

27 Dec 2008, 3:26 PM
#6
ckosloff avatar

ckosloff

Totally Zenned

Join Date:
Feb 2007
Location:
South Florida, USA
Posts:
1,375
Plugin Contributions:
0

Re: Where to enter a javascript that goes in header?

DrByte:

That would be an ugly hack, and doesn't use the built-in autoplugin capability.
As the wiki article states, as well as the docs in the /docs/ folder of your Zen Cart files, you simply create a jscript_whatever.js file in the jscript folder of your template, and its contents will be automatically referenced in the <head> section of your pages. The article goes into detail of various alterations supported.
I tried loading a javascript the way you describe.
It worked, but...since IH2 loads its own jscript in same folder it broke the hover functionality in IH2.
Something to be aware of...

27 Dec 2008, 3:39 PM
#7
ckosloff avatar

ckosloff

Totally Zenned

Join Date:
Feb 2007
Location:
South Florida, USA
Posts:
1,375
Plugin Contributions:
0

Re: Where to enter a javascript that goes in header?

All right, it won't break IH2 if the jscript includes the <script> tags and is renamed to the .php extension.