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)
-   -   how do I remove spaces in sharing button urls (https://forum.x-cart.com/showthread.php?t=71788)

keystone 04-07-2015 10:27 AM

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.

PhilJ 04-07-2015 10:40 AM

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>


keystone 04-07-2015 12:01 PM

Re: how do I remove spaces in sharing button urls
 
that worked, thanks Phil.


All times are GMT -8. The time now is 01:18 AM.

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