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

how do I remove spaces in sharing button urls

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 04-07-2015, 10:27 AM
 
keystone keystone is offline
 

X-Adept
  
Join Date: Jul 2006
Location: USA
Posts: 787
 

Default how do I remove spaces in sharing button urls

I have sharing buttons on my site. An example of one is for twitter. Here is the template code that creates the link from my product.

Code:
<a class="btn btn-info ttip_n" title="Twitter" href="//twitter.com/intent/tweet?text={$product.product}&amp;url={$http_location}/{$canonical_url}&amp;via={$config.Company.company_name}" target="_blank"> <i class="fa fa-twitter"></i> </a>

The problem is that my product names have spaces in them so the actual URL comes out looking like this.
Code:
<a class="btn btn-info ttip_n" title="Twitter" href="//twitter.com/intent/tweet?text=Balsam Fir 2x3 Pillar Candles&amp;url=http://www.uscandleco.com/product.php?productid=153728&amp;via=U.S. Candle Company" target="_blank"> <i class="fa fa-twitter"></i> </a>

Is there a way to replace the spaces in the URL with + or %20 so that they will validate in w3c?

Thanks.
__________________
www.uscandleco.com - X-Cart Version 4.7.11 Gold Plus php7.3
mods:
reCaptcha
running on UNIX

www.keystonecandle.com X-Cart Gold Plus - Version 4.7.11 php7.2
mods:
reCaptcha
cdseo pro
running on UNIX
Reply With Quote
  #2  
Old 04-07-2015, 10:40 AM
 
PhilJ PhilJ is offline
 

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

Default Re: how do I remove spaces in sharing button urls

Try...
Code:
<a class="btn btn-info ttip_n" title="Twitter" href="//twitter.com/intent/tweet?text={$product.product|replace:" ":"%20"}&amp;url={$http_location}/{$canonical_url}&amp;via={$config.Company.company_name|replace:" ":"%20"}" target="_blank"> <i class="fa fa-twitter"></i> </a>
__________________
xcartmods.co.uk
Reply With Quote
  #3  
Old 04-07-2015, 12:01 PM
 
keystone keystone is offline
 

X-Adept
  
Join Date: Jul 2006
Location: USA
Posts: 787
 

Default Re: how do I remove spaces in sharing button urls

that worked, thanks Phil.
__________________
www.uscandleco.com - X-Cart Version 4.7.11 Gold Plus php7.3
mods:
reCaptcha
running on UNIX

www.keystonecandle.com X-Cart Gold Plus - Version 4.7.11 php7.2
mods:
reCaptcha
cdseo pro
running on UNIX
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 08:58 PM.

   

 
X-Cart forums © 2001-2020