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)
-   -   Help Please! (https://forum.x-cart.com/showthread.php?t=48140)

club13 06-17-2009 09:09 AM

Help Please!
 
Need to add external java script to individual product pages. This is the script:

<script src="http://www.yakkingheads.com/sample.js"> </script>


The script is for a talking pop-up spokesperson. I need it to open up on each product page. I got it to work home the home page on xcart by placing it in the customer/home.tpl head section. But cannot figure it out how to get it to work on individual product pages. Please help.

Victor D 06-17-2009 05:51 PM

Re: Help Please!
 
Do you need this script on product pages only?
Try
Code:

{if $main eq "product"}<script src="http://www.yakkingheads.com/sample.js">  </script>{/if}

club13 06-18-2009 04:09 PM

Re: Help Please!
 
Yes that code works, but I need to have a different script open for different products. Any help would be great. Thanks

Victor D 06-19-2009 01:41 AM

Re: Help Please!
 
The simplest solution is
Code:

{if $main eq "product"}<script src="http://www.yakkingheads.com/sample
{$product.productid}.js">  </script>{/if}


For more flexibility you will need an extra field

club13 06-19-2009 08:46 AM

Re: Help Please!
 
How would I put the product id in the above script? Also what is the product id? The sku? or the product name? Thanks

Victor D 06-19-2009 12:31 PM

Re: Help Please!
 
productid is an numeric internal xcart value. It is used in database as a primary key so it is unique. If you browse to any product you will see URL like this
http://yourstore/product.php?productid=14334
14334 is a productid

you can also use SKU:
Code:

{if $main eq "product"}<script src="http://www.yakkingheads.com/sample
{$product.productcode|escape}.js">  </script>{/if}


or even product title:

Code:

{if $main eq "product"}<script src="http://www.yakkingheads.com/sample
{$product.producttitle|escape}.js">  </script>{/if}


but in last two cases you can get an invalid URL for your script as either title or SKU may contains characters that are not allowed to use in URI

club13 06-19-2009 01:01 PM

Re: Help Please!
 
Thanks, but It still opens on every product page? I m having a brain fart today. Can you give me the code for it to work if my product id is: 16199

Thanks for all your help.

ARW VISIONS 06-20-2009 12:37 AM

Re: Help Please!
 
{if $product.productid eq 123456}

insert your product id

club13 06-20-2009 12:41 PM

Re: Help Please!
 
This is the code I used:

{if $main eq "product"}<script src="http://www.yakkingheads.com/sample
{$product.16199}.js"> </script>{/if}

It works, but it opens up on every product page. I need it to only open on the product page that has the product id of 16199

Anymore help would be great. Thanks.

ARW VISIONS 06-20-2009 02:33 PM

Re: Help Please!
 
{if $product.productid eq 16199}<script src="http://www.yakkingheads.com/sample
.js"> </script>{/if}

club13 06-23-2009 12:49 PM

Re: Help Please!
 
Thank You. Works Great...


All times are GMT -8. The time now is 02:59 PM.

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