Just needed to add share buttons for Twitter and Facebook for a site and rather than add javascript or a module for handling them I wondered if you could just use some smarty tags to build the links ... and of course you can:
Code: Select all
{capture assign="currenturl"}http://{$smarty.server.HTTP_HOST}{$smarty.server.REQUEST_URI}{/capture}
<a class="twitIntent" href="https://twitter.com/intent/tweet?url={$currenturl|escape:'url'}"><span>Share on Twitter</span></a>
<a class="fbIntent" href="http://www.facebook.com/sharer.php?u={$currenturl|escape:'url'}">Share on Facebook</a>
That captures the URL of the page you're looking at (so it works for blog posts etc) then uses Smarty's escape modifier to encode the url to add to our Twitter / Facebook intent links.