X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   adding javascript to customer home.tpl (https://forum.x-cart.com/showthread.php?t=36794)

dgallek 01-16-2008 01:10 PM

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

balinor 01-16-2008 04:07 PM

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 :)

dgallek 01-17-2008 05:37 AM

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?

inebriate 01-17-2008 02:47 PM

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

dgallek 01-21-2008 09:41 AM

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

dgallek 01-22-2008 10:17 AM

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}>


All times are GMT -8. The time now is 05:42 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.