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

Help Please!

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 06-17-2009, 09:09 AM
 
club13 club13 is offline
 

Member
  
Join Date: Jul 2008
Posts: 28
 

Default 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.
__________________
4.1.10

http://www.club13.com
Reply With Quote
  #2  
Old 06-17-2009, 05:51 PM
  Victor D's Avatar 
Victor D Victor D is offline
 

X-Adept
  
Join Date: Aug 2008
Posts: 643
 

Default 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}
__________________
Regards,
Victor Dubiniuk

X-Cart Skins Store
- twenty two different skins for 4.1.x and 4.2.x;
- 4.3.x compatible versions are available;
- refresh you store now!

Smart menu X-Cart add-on for 4.1.8 - 4.3.x
Featured Products Slide Show X-Cart add-on for 4.1.8 - 4.3.x
Reply With Quote
  #3  
Old 06-18-2009, 04:09 PM
 
club13 club13 is offline
 

Member
  
Join Date: Jul 2008
Posts: 28
 

Default 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
__________________
4.1.10

http://www.club13.com
Reply With Quote
  #4  
Old 06-19-2009, 01:41 AM
  Victor D's Avatar 
Victor D Victor D is offline
 

X-Adept
  
Join Date: Aug 2008
Posts: 643
 

Default 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
__________________
Regards,
Victor Dubiniuk

X-Cart Skins Store
- twenty two different skins for 4.1.x and 4.2.x;
- 4.3.x compatible versions are available;
- refresh you store now!

Smart menu X-Cart add-on for 4.1.8 - 4.3.x
Featured Products Slide Show X-Cart add-on for 4.1.8 - 4.3.x
Reply With Quote
  #5  
Old 06-19-2009, 08:46 AM
 
club13 club13 is offline
 

Member
  
Join Date: Jul 2008
Posts: 28
 

Default 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
__________________
4.1.10

http://www.club13.com
Reply With Quote
  #6  
Old 06-19-2009, 12:31 PM
  Victor D's Avatar 
Victor D Victor D is offline
 

X-Adept
  
Join Date: Aug 2008
Posts: 643
 

Default 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
__________________
Regards,
Victor Dubiniuk

X-Cart Skins Store
- twenty two different skins for 4.1.x and 4.2.x;
- 4.3.x compatible versions are available;
- refresh you store now!

Smart menu X-Cart add-on for 4.1.8 - 4.3.x
Featured Products Slide Show X-Cart add-on for 4.1.8 - 4.3.x
Reply With Quote
  #7  
Old 06-19-2009, 01:01 PM
 
club13 club13 is offline
 

Member
  
Join Date: Jul 2008
Posts: 28
 

Default 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.
__________________
4.1.10

http://www.club13.com
Reply With Quote
  #8  
Old 06-20-2009, 12:37 AM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: Help Please!

{if $product.productid eq 123456}

insert your product id
__________________
xcart 5.1.2
Reply With Quote
  #9  
Old 06-20-2009, 12:41 PM
 
club13 club13 is offline
 

Member
  
Join Date: Jul 2008
Posts: 28
 

Default 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.
__________________
4.1.10

http://www.club13.com
Reply With Quote
  #10  
Old 06-20-2009, 02:33 PM
  ARW VISIONS's Avatar 
ARW VISIONS ARW VISIONS is offline
 

X-Man
  
Join Date: Jan 2007
Location: Pensacola, FL
Posts: 2,536
 

Default Re: Help Please!

{if $product.productid eq 16199}<script src="http://www.yakkingheads.com/sample
.js"> </script>{/if}
__________________
xcart 5.1.2
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 10:39 PM.

   

 
X-Cart forums © 2001-2020