10/06/2010

add facebook share button in magento

You can get Facebook share button from http://www.facebook.com/share/. But to add this in magento you need to get the current page url.
From the below code you can get the Current page Url in magento
<?php 
echo $currUrl= $this->getUrl('').$_SERVER['REQUEST_URI'];
?>
Now Write this code into the header/footer section of your site To see the Share Button
<a name="fb_share" type="button" href="http://www.facebook.com/sharer.php?u=<?php echo $currUrl;?>">Share</a>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>

2 comments:

  1. thank you for share this tutorial

    ReplyDelete
  2. Excellent I was searching for long time on net and finally got your code. Once again thanks.

    ReplyDelete