Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

adding javascript to customer home.tpl

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 01-16-2008, 01:10 PM
 
dgallek dgallek is offline
 

Member
  
Join Date: Mar 2007
Posts: 10
 

Default adding javascript to customer home.tpl

Hi All,

I'm trying to get two javascript functions to run on the home.tpl

I've put the relevant script info between the "literal" tags as below:


Code:
</title> {include file="meta.tpl" } <link rel="stylesheet" href="{$SkinDir}/{#CSSFile#}" /> {literal} <script type="text/JavaScript"> function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> <script type="text/javascript" src="../../template-files/p7pm/p7popmenu.js"></script> <link rel="stylesheet" href="../../template-files/p7pm/p7pmh0.css" TYPE="text/css" MEDIA="screen" /> <style type="text/css" media="screen"> <!-- @import url("../../template-files/p7pm/p7pmh0.css"); .style3 {color: #000000} h1 { font-size: 16px; color: #FFFFFF; } h2 { font-size: 14px; color: #000000; } h3 { font-size: 18px; color: #FFFFFF; } .style4 {color: #FFFFFF; } --> </style> </literal> </head>

And, I've added the onload call in the body tag:

Code:
<body{$reading_direction_tag}{if $body_onload ne ''} onload="javascript: MM_preloadImages('../../template-files/2newsletter.jpg','../../template-files/2festool.jpg','../../template-files/2internetstore.jpg','../../template-files/2flitch.jpg','../../template-files/2cart_empty.gif');{$body_onload}"{/if}> {include file="rectangle_top.tpl" } {include file="head.tpl" }

When I view the page at http://www.hearnehardwoods.com/xcart/home.php?shopkey=9779

Everything works except the dropdowns for:
Homepage Our Woods Internet Store Customers Contact Us

and

the rollovers (Dreamweaver) just above the menu and to the right (there are 4 image buttons with text on them)

Everything works correctly here:
http://www.hearnehardwoods.com/about_us/policies.html

I'm running XCart Gold version 4.1.6

Thanks in advance,
Debra
__________________
X-Cart v4.1.6
Reply With Quote
  #2  
Old 01-16-2008, 04:07 PM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: adding javascript to customer home.tpl

Your closing literal tag is wrong, it should be {/literal} not </literal>

Also, can you please update your forum signature with your X-Cart version? Thank you
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 01-17-2008, 05:37 AM
 
dgallek dgallek is offline
 

Member
  
Join Date: Mar 2007
Posts: 10
 

Default Re: adding javascript to customer home.tpl

thanks for looking at my coding and telling me where the error was. I've fixed that but have a new issue.

The drop down menu is is not working - the sub-menus don't expand over the Search bar, see:

http://www.hearnehardwoods.com/xcart/home.php?shopkey=9779


However, the same javascript code does work here:
http://www.hearnehardwoods.com/about_us/policies.html

Does you have any ideas about what I could do?
__________________
X-Cart v4.1.6
Reply With Quote
  #4  
Old 01-17-2008, 02:47 PM
 
inebriate inebriate is offline
 

eXpert
  
Join Date: May 2006
Posts: 301
 

Default Re: adding javascript to customer home.tpl

you may want to check the folder structure since you are using "../../" and your xcart and the aboutus are different directories
__________________
x-cart pro 4.0.18
linux
www.fabric8d.com (currently undergoing construction)
Reply With Quote
  #5  
Old 01-21-2008, 09:41 AM
 
dgallek dgallek is offline
 

Member
  
Join Date: Mar 2007
Posts: 10
 

Default Re: adding javascript to customer home.tpl

thanks inebriate,

I double checked my directory path statements and they are valid.

To test, I created a test.js javascript file and placed it in the same folder that the drop down menu javascript file (p7popmenu.js) is, loaded the test.js w/in home.tpl (exactly as I did for p7popmenu.js) and called for the function (contained in the test.js file) in head.tpl and it works.

Whereas calling for the function contained in the p7popmenu.js in the head.tpl does not work.

I also tried put the actual javascript for the drop down menu into the home.tpl but that also did not work.

This is the "preview" of my head.tpl, at the top you can see the date modified that is generated by test.js, just below the banner images, you can see my drop down menu (this is what it would look like in a non-css compatible browser) -- don't know if that helps anything, but here;s the link:

http://www.hearnehardwoods.com/xcart/test.gif

http://www.hearnehardwoods.com/xcart/test.gif
__________________
X-Cart v4.1.6
Reply With Quote
  #6  
Old 01-22-2008, 10:17 AM
 
dgallek dgallek is offline
 

Member
  
Join Date: Mar 2007
Posts: 10
 

Default Re: adding javascript to customer home.tpl

Found the problem - it has to do with how my "<body onload" coding was done.

The correct code order is:

Code:
<body onload="P7_initPM(1,0,1,0,0);MM_preloadImages('../../template-files/2newsletter.jpg','../../template-files/2festool.jpg','../../template-files/2internetstore.jpg','../../template-files/2flitch.jpg','../../template-files/2cart_empty.gif')"{$reading_direction_tag}{if $body_onload ne ''} {$body_onload} {/if}>
__________________
X-Cart v4.1.6
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 10:55 PM.

   

 
X-Cart forums © 2001-2020