Welcome to the blog Hitech Tips

A blog about web and IT. Sharing things I use at work.

How to Add Facebook's New "Like" Button to Blogger

Posted by Mr.Editor Thursday, April 22, 2010

image
Facebook just lunched the "Like" button to be used in any page. To have it in your Blogger blog, do the following steps:

  1. First, do a backup of your blogger template (see it here: Template actions: download, backup, edit and restore) .
  2. Then edit your template and find the following text in the XML code:
    <data:post.body/>
    Tip: if you can't find it, try to search data:post.body until there is something similar and that ends with />

  3. Place the following code after that line:
    <iframe allowTransparency='true' expr:src='"http://www.facebook.com/plugins/like.php?href=" + data:post.url + "&amp;layout=standard&amp;show-faces=true&amp;width=530&amp;height=60&amp;action=like&amp;colorscheme=light"' frameborder='0' scrolling='no' style='border:none; overflow:hidden; width:530px; height:60px'/>



    Result:
    image

    Changing the Like' button to 'Recommend'
    If you prefer that your button says "Recommend" instead of "Like", it is just necessary to change the code of point 3: just change the action=like to say action=recommend. The following code does that:


    <iframe allowTransparency='true' expr:src='"http://www.facebook.com/plugins/like.php?href=" + data:post.url + "&amp;layout=standard&amp;show-faces=true&amp;width=530&amp;height=60&amp;action=recommend&amp;colorscheme=light"' frameborder='0' scrolling='no' style='border:none; overflow:hidden; width:530px; height:60px'/>



    Result:
    image

  4. Save the template and that's it.


There are other ways of doing this but the one recommended by Facebook (see here) won't work because it gives an Blogger gives an error when the template is being saved.  Also, the approach given  by Facebook won't allow individual "Likes" for each post (only for the whole blog).

Finally, If you prefer using the Facebook API ( to leave a comment on the "Liked" item), just have a look here.


7 comments

  1. Asfan Ash Says:
  2. nice 1 bro. Ive republished this entry into my language. and backlinked u as well. Hope y dont mind

    btw, facebook actually allows us to like each entry. Ive checked it

     
  3. awesome time saver ! thanks a lot !

     
  4. The Hilmans Says:
  5. how come i dont have that data:post.body or anything similar?
    just got post.body without /> at the end...help!!

     
  6. Hi

    Be sure that you have expanded the widgets. Have a look here:

    Template actions: download, backup, edit and restore

    Any way, if you still have problems, you can mail me your template code, I can have a look:

    fliscorno at gmail dot com

    Cheers,
    Jorge

     
  7. Note: don't forget to have also a look here:

    Facebook Like button XFBML tutorial

    It's a tutorial, where I show how to have the Like button with the possibility of adding a comment after the Like.

     
  8. Laura Says:
  9. Thanks so much for that! It worked beautifully! I've posted this page to my facebook profile.

     
  10. This sounds complicated for someone who isn't familiar with html.

     

Post a Comment

Followers