Monday Jun 7 '10 - Written by Qasim

After searching around in vain this morning for a module to include the nifty Facebook Like widget on some client sites I came to the realization that it should work just like the Tweetmeme solution I cooked up back in December last year.

The idea is that Facebook gives you an iframe tag to use per domain - so instead of hard-coding a URL into the code to let people 'like' a specific page just make that URL call dynamic using the PHP so that the tag works on any node you want it on.  From there all you have to do is embed the code in a node-type.tpl.php template file and boom you're off! 

Here's the code with a wrapper div you can use via CSS for extra positioning etc: What you'll notice is that you don't have to do much - just get the code from facebook then include your own root URL and add the php to call specific nodes right after it :

<?php print $node_url ?>

You can see this in action here on the Why Drupal blog at the end of each post.