Adding a Facebook "Like" block to your Drupal site
I just added the newly announced "Like" button to my blog. It's very easy to do on Drupal.
First, enable PHP input format...
In Drupal 6, the PHP input format is not enabled by default - it has to be enabled by enabling an additional module. So go to admin/build/modules and enable:
PHP filter 6.8 Allows embedded PHP code/snippets to be evaluated.
Next, create your new block...
Go to #Administer, #Site building, #Blocks
Click on the "add blocks" tab
Enter in a Block description and put the following in the Block body:
<iframe id="iframe_like" name="fbLikeIFrame_0" class="social-iframe" scrolling="no" frameborder="0" src="http://www.facebook.com/widgets/like.php?width=100&show_faces=1&layout=standard&href=<?php $curr_url = check_plain("http://" .$_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI']); echo $curr_url; ?>" width=100 height=300></iframe>
Change the "Input format" to "PHP Code"
Save it and you're done!

Thanks
Hi, thanks so much for this. Been looking everywhere. Works ok, except that when I click "Like" (I am already signed in on FB), this pops up in a new window (with a facebook.com header):
"The page at http://<?php%20$curr_url%20=%20check_plain( could not be reached."
Fiddled with it as much as possible but nothing took. Can you help?
It appears that you don't
It appears that you don't have "PHP Code" enabled for your page/post.
Post new comment