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

Add Button To Search An External Site

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 12-09-2009, 03:31 AM
 
flamers flamers is offline
 

Advanced Member
  
Join Date: Nov 2004
Posts: 51
 

Default Add Button To Search An External Site

We have a DVD store, and have just affiliated with a Video on Demand supplier. What we want to do is to add a button to the product page inbetween the Add To Cart and Add To Wish List buttons which, when clicked, goes to the same product on the Video on Demand site.

Making the button is easy, we cloned the existing Add To Cart button and created a new template in Buttons. However, I can't get my head around how I pull the product name off the page to create the external hyperlink.

In a nutshell, in customer/main/product.tpl the following code controls adding a product to the cart:

{include file="buttons/add_to_cart.tpl" style="button" href="javascript: if(FormValidation()) document.orderform.submit();"}

what we need to do is amend that to something like:

{include file="buttons/video_on-demand.tpl" style="button" href="http://www.sitenamehere.com/search/super_search.jhtml?action=newSearch&sources=gl&sea rchTerms=TERM1+TERM2"}

where sitenamehere is the external site, and TERM1 and TERM2 are the words in the item name conjoined by +.

The code: http://www.sitenamehere.com/search/super_search.jhtml?action=newSearch&sources=gl&sea rchTerms=

will never change

So the question is: how can I suck the product name from the page and insert it into TERM1+TERM2?

Any guidance would be appreciated.
__________________
X-Cart V 4.0.18
Reply With Quote
  #2  
Old 12-09-2009, 06:36 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Add Button To Search An External Site

Maybe try...
Code:
{include file="buttons/video_on-demand.tpl" style="button" href=http://www.sitenamehere.com/search/super_search.jhtml?action=newSearch&sources=gl&searchTerms=`$product.product|replace:" ":"+"`}
__________________
xcartmods.co.uk
Reply With Quote
  #3  
Old 12-09-2009, 09:10 AM
 
flamers flamers is offline
 

Advanced Member
  
Join Date: Nov 2004
Posts: 51
 

Default Re: Add Button To Search An External Site

Thanks PhilJ, tried it but I get an invalid attribute name error for this piece of code:

'$product.product|replace:" ":"+"'}

The error message is: Fatal error: Smarty error: [in customer/main/product.tpl line 130]: syntax error: invalid attribute name: '":"+' (Smarty_Compiler.class.php, line 1524)

I'm getting a bit lost because it's been a long and busy day and my head is swimming!
__________________
X-Cart V 4.0.18
Reply With Quote
  #4  
Old 12-09-2009, 09:50 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Re: Add Button To Search An External Site

ok this'll work...
Code:
{capture name=vodterms} {$product.product|replace:" ":"+"} {/capture}
Then...
Code:
{include file="buttons/video_on-demand.tpl" style="button" href="http://www.sitenamehere.com/search/super_search.jhtml?action=newSearch&sources=gl&searchTerms=`$smarty.capture.vodterms`"}
__________________
xcartmods.co.uk
Reply With Quote
  #5  
Old 12-10-2009, 08:40 AM
 
flamers flamers is offline
 

Advanced Member
  
Join Date: Nov 2004
Posts: 51
 

Default Re: Add Button To Search An External Site

Once again, thanks PhilJ, that works perfectly insofar as it pulls the product name down and inserts it into the hyperlink. However (you probably knew that was coming) the button isn't clickable, so I need to make that part work so it will actually direct the user off to the other site. I'd appreciate your, or anyone else's(!) help in the coding for this, and just to be REALLY demanding I would like it to open in a new window(target=_blank), thus leaving our site open so we don't lose the customer.

Thanks!
__________________
X-Cart V 4.0.18
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 02:33 PM.

   

 
X-Cart forums © 2001-2020