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

Banner Rotating Script - Smarty Error

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-25-2007, 03:17 PM
 
jeff819 jeff819 is offline
 

Advanced Member
  
Join Date: May 2006
Posts: 42
 

Default Banner Rotating Script - Smarty Error

I am trying to use this banner rotating script on my homepage, but I get a smarty error when inserting it into welcome.tpl. I haven't changed the images/links in the code because I just want to get it functioning first...

Can someone tell me what might be causing the smarty error in the following code?

Code:
<script language="Javascript"> <!-- // original content taken from Nic's JavaScript Page with permission // lack of these three lines will result in copyright infringment // made by: Nic's JavaScript Page - http://www.javascript-page.com var currentdate = 0; var core = 0; function initArray() { this.length = initArray.arguments.length; for (var i = 0; i < this.length; i++) { this[i] = initArray.arguments[i]; } } link = new initArray( "http://3bgraphics.hypermart.net/", "http://html.digitalsea.net/", "http://www.javascript-page.com/" ); image = new initArray( "http://3bgraphics.hypermart.net/link/3bgraphics.gif", "http://html.digitalsea.net/htmlnow.gif", "http://www.geocities.com/~jsmaster/jsnow.gif" ); text = new initArray( "3B Graphics", "Learn HTML in 7 Easy Steps", "Nic's JavaScript Page" ); var currentdate = new Date(); var core = currentdate.getSeconds() % image.length; var ranlink = link[core]; var ranimage = image[core]; var rantext = text[core]; document.write('<a href=\"' +ranlink+ '\" target=\"_blank\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a>'); //--> </SCRIPT>

Thanks,
Jeff
__________________
X-Cart Gold - Version 4.0.19
Reply With Quote
  #2  
Old 04-25-2007, 05:20 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: Banner Rotating Script - Smarty Error

Insert literal tags around the code like so:

Code:
{literal}
<script language="Javascript"> <!-- // original content taken from Nic's JavaScript Page with permission // lack of these three lines will result in copyright infringment // made by: Nic's JavaScript Page - http://www.javascript-page.com var currentdate = 0; var core = 0; function initArray() { this.length = initArray.arguments.length; for (var i = 0; i < this.length; i++) { this[i] = initArray.arguments[i]; } } link = new initArray( "http://3bgraphics.hypermart.net/", "http://html.digitalsea.net/", "http://www.javascript-page.com/" ); image = new initArray( "http://3bgraphics.hypermart.net/link/3bgraphics.gif", "http://html.digitalsea.net/htmlnow.gif", "http://www.geocities.com/~jsmaster/jsnow.gif" ); text = new initArray( "3B Graphics", "Learn HTML in 7 Easy Steps", "Nic's JavaScript Page" ); var currentdate = new Date(); var core = currentdate.getSeconds() % image.length; var ranlink = link[core]; var ranimage = image[core]; var rantext = text[core]; document.write('<a href=\"' +ranlink+ '\" target=\"_blank\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\"></a>'); //--> </SCRIPT> {/literal}
Reply With Quote
  #3  
Old 04-25-2007, 06:32 PM
 
jeff819 jeff819 is offline
 

Advanced Member
  
Join Date: May 2006
Posts: 42
 

Default Re: Banner Rotating Script - Smarty Error

Thanks Jon...that worked perfectly!

So are these {literal} tags necessary for any Javascript code?

Jeff
__________________
X-Cart Gold - Version 4.0.19
Reply With Quote
  #4  
Old 04-25-2007, 07:41 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: Banner Rotating Script - Smarty Error

Javascript code often has tags such as brackets which smarty will try to interpret as smarty code, the literal tags says to take it literally and not parse it. In short, javascript doesn't always need the literal tags, but most often does.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 09:36 AM.

   

 
X-Cart forums © 2001-2020