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)
-   -   Include javascript in custom .tpl (https://forum.x-cart.com/showthread.php?t=45489)

ChristineP 02-11-2009 05:51 AM

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

balinor 02-11-2009 06:07 AM

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}

ChristineP 02-11-2009 06:21 AM

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


All times are GMT -8. The time now is 01:45 PM.

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