Thursday, December 12, 2013

Add social buttons with Grails

Here is a simple way to add social button without time'sloading problems.

Example :


            <a target="_blank" title="Twitter" href="https://twitter.com/share?url=<g:createLink action="${params.action}" absolute="true"/>&text=<g:message code="training.title" /> sur <g:createLink action="${params.action}" absolute="true"/>" class="tweet-button" rel="nofollow" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=400,width=700');return false;"><img src="/fjLearning/images/twitter_icon.png" width="32" height="32"/></a>


In this example, we used <g:createLink action="${params.action}" absolute="true"/> to generate full url of your gsp web page.
params.action variable contains current action.

If you want other example (Facebook, Google + ...), you can see that link : http://korben.info/bouton-partage-twitter-facebook-sans-tracking.html