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 Roll Over images (https://forum.x-cart.com/showthread.php?t=19799)

dprice.sf 02-07-2006 02:58 PM

Adding Roll Over images
 
Hi - I've got some product images i'll ideally have on the bottom of every page as roll overs.

I've edited my home.tpl file with the roll over images and included a newly created roll.js file to handle the js.

when i try and load the home page now - i get a smarty error

Fatal error: Smarty error: [in roll.js line 1]: syntax error: unrecognized tag 'var' (Smarty_Compiler.class.php, line 580) in /homepages/34/d145649509/htdocs/mikan/store/Smarty-2.6.9/Smarty.class.php on line 1088

anyone have any ideas on how best to incorporate js into pages?

balinor 02-07-2006 03:14 PM

You need to surround the js with literal tags:

{literal}script here{/literal}

dprice.sf 02-07-2006 03:30 PM

like this

Code:

{literal}
function MM_swapImgRestore() {
  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() {
  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) {
  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() {
  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];}
}
{/literal}


balinor 02-07-2006 03:33 PM

No, it needs to surround the entire script, including the opening and closing javascript tags.

dprice.sf 02-07-2006 03:34 PM

or this

{literal}
{ include file="roll.js" }
{/literal}

dprice.sf 02-07-2006 04:15 PM

thanks balinor. I was able to figure it out.

found this site to be helpful as well

http://www.phpfreaks.com/smarty_manual/page/language.function.literal.html

dprice.sf 02-08-2006 11:33 AM

Is there a trick to getting the embedded static pages to use js ?

tried the same approach as discussed above - doesn't seem to work here though

balinor 02-08-2006 12:39 PM

Check the 'allow smarty in static pages option.


All times are GMT -8. The time now is 07:08 AM.

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