AltJ.com, the blog

Some geek stuff, some not so geek stuff.

Technology

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:


Change the “Input format” to “PHP Code”

Save it and you’re done!

Bluehost.com Web Hosting $6.95

  1. Sneha

    December 15, 2010 at 2:05 pm

    great! Seems like easiest way I’ve found yet. I’ll try it.

  2. Ausra

    January 13, 2011 at 2:34 am

    Hello, Dear 🙂
    Please, help me.. I did everything, like You recommended, but i cannot see the Facebook like button, only the name of the Block and the same text which You suggested to put in the Block body 🙁
    Maybe You know how could i fix it?
    Thankfully,
    Ausra.

    1. AltJ

      January 13, 2011 at 9:56 am

      Hi Ausra,
      Make sure you have changed the “Input format” to “PHP Code”

      Alt

  3. amurobo

    March 1, 2011 at 11:40 pm

    Thanks so much JerryJr!!! it works like a charm!!

    I have another facebook share module and I needed to fix the width to 60% to make them align.

  4. Franz

    July 5, 2011 at 7:37 pm

    It is easy. However, it’s not good to have PHP Filter module enabled on any production site, for security reasons (http://drupal.org/node/1203886). Even if it’s only for admin users, custom block code done in DB is harder to maintain and deploy, so it’s advisable to create a simple, short module implementing the Block API to create this custom block (see http://api.drupal.org/api/drupal/developer–hooks–core.php/function/hook_block/6)

Comments are closed.