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

Include javascript in custom .tpl

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-11-2009, 05:51 AM
 
ChristineP ChristineP is offline
 

eXpert
  
Join Date: Jul 2008
Posts: 310
 

Default Include javascript in custom .tpl

How do I include javascript into a custom mod.

Can I place the entire javascript and form within my custom .tpl with {literal} before and after <script> to make this work, or is there a best X-Cart/Smarty practice to accomplish this?

I've looked around in other .tpl and I found <script type="text/javascript" src="{$SkinDir}/folder/jsname.js"></script> into the top portion of the .tpl by spliting the script from the form and uploading the script to the appropriate folder. I've tried adding {include file="folder/jsname.js"} to call out that .js file, but no cigar. Also, I looked in an include/???.php file and found:
<script language='JavaScript'>
alert('$txt_message');
self.location='$to_url';
</script>

Would this mean that I need to create a .php file for the javascript and form that I want to use?

Christine
__________________
______________
version 4.1.9 Gold
Reply With Quote
  #2  
Old 02-11-2009, 06:07 AM
 
balinor balinor is offline
 

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

Default Re: Include javascript in custom .tpl

Just put it right in your template:

{literal}<script language='JavaScript'>
alert('$txt_message');
self.location='$to_url';
</script>{/literal}
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote

The following user thanks balinor for this useful post:
ChristineP (02-11-2009)
  #3  
Old 02-11-2009, 06:21 AM
 
ChristineP ChristineP is offline
 

eXpert
  
Join Date: Jul 2008
Posts: 310
 

Default Re: Include javascript in custom .tpl

Awesome, thank you. I got it working, but I'm not versed enough with the constraints of X-Cart-Smarty tags to know whether I will break something in X-Cart. These forums are a great help!

Thanks again,
Christine
__________________
______________
version 4.1.9 Gold
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 09:20 AM.

   

 
X-Cart forums © 2001-2020