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

Having trouble inserting javascript into home.tpl <head> section

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 06-02-2007, 09:24 AM
 
simcomedia simcomedia is offline
 

Advanced Member
  
Join Date: Sep 2006
Posts: 95
 

Default Having trouble inserting javascript into home.tpl <head> section

I'm modifying the design to include a horizontal javascript rollover menu that I created in Photoshop. Here's my modified head.tpl <head> section including the javascript inserted:

{* $Id: home.tpl,v 1.19.2.5 2006/10/24 13:46:18 svowl Exp $ *}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{if $printable ne ''}
{include file="customer/home_printable.tpl"}
{else}
{config_load file="$skin_config"}
<html>
<head>
<title>
{if $config.SEO.page_title_format eq "A"}
{section name=position loop=$location}
{$location[position].0|strip_tags|escape}
{if not %position.last%} :: {/if}
{/section}
{else}
{section name=position loop=$location step=-1}
{$location[position].0|strip_tags|escape}
{if not %position.last%} :: {/if}
{/section}
{/if}
</title>
<script type="text/javascript">
<!--

function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}

function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
}
}
}

var preloadFlag = false;
function preloadImages() {
if (document.images) {
contact_over = newImage("images/contact-over.gif");
cart_over = newImage("images/cart-over.gif");
reseller_over = newImage("images/reseller-over.gif");
preloadFlag = true;
}
}

// -->
</script>

{include file="meta.tpl" }
<link rel="stylesheet" href="{$SkinDir}/{#CSSFile#}" />

</head>

When I insert this I get this Smarty template error:

Quote:
Error: Smarty error: [in customer/home.tpl line 25]: syntax error: unbalanced parenthesis in if statement (Smarty_Compiler.class.php, line 1265) in /home2/wwwtren/public_html/Smarty-2.6.12/Smarty.class.php on line 1095

I don't get why Smarty is trying to parse the 'if' statements of the javascript and what it's looking for in order to fix it.

Anyone have a solution?
__________________
Custom Designs - Web Templates
www.templatedepot.com
Reply With Quote
  #2  
Old 06-02-2007, 12:03 PM
 
balinor balinor is offline
 

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

Default Re: Having trouble inserting javascript into home.tpl <head> section

You need to surround the js with literal tags:

{literal}
Javascript here
{/literal}
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
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 03:15 PM.

   

 
X-Cart forums © 2001-2020