Social Plugins

Last updated on
30 April 2025

Social Plugins are appropriate when you have a website and want to add some social features, but do not want to host a full-fledged Facebook application. This a relatively quick and easy way to add Like Buttons, Activity Feeds, Recommendations, and more to your website.

Drupal for Facebook takes care of loading and initializing Facebook's javascript libraries. So as the site developer, you need only add simple XFBML tags to your markup. Adding Facebook's markup to your pages is like adding regular HTML tags. Drupal gives you lots of ways to do this, including content (nodes), blocks, and custom code.

Add a Social Plugin to a Block

Required modules

  • fb.module - which is automatically included when you install modules/fb 3.x

Settings and Configuration

In order to display FBML tags correctly, IE requires the attribute xmlns:fb="http://www.facebook.com/2008/fbml" in the <html> tag, which is part of your theme's html.tpl.php file (page.tpl.php for Drupal 6 and previous versions). More detailed information can be found on the Installation page.

How to add a social plugin to a block

  • Using Drupal's admin interface, navigate to Admin >> Site Building >> Blocks
  • Click "add block"
  • In the block body, paste the social plugin markup. For an Activity Feed, this looks like:
    <fb:activity site="http://example.com"></fb:activity>
    
  • Open the "input format" fieldset, and select a format such as "Full HTML" or "PHP".

    The default input format, "filtered HTML" will strip FBML tags, so it is very important to select an input format which will render the markup properly as shown below. Note that in Drupal 7, you may need to use the PHP input filter as even the default Full HTML filter will strip FBML tags.

Add a Social Plugin to a Node

Required modules

  • Same as above

Settings and Configuration

  • Same as above

How to add a social plugin to a node

  • Using Drupal's admin interface, navigate to Admin >> Create Content >>Page (story, article, etc.)
  • In the node body, paste the social plugin markup. For a Like Button, this looks like:
    <fb:like></fb:like>
    
  • Click "Save" and you'll see the Like Button as shown below
  • However, if instead of the Like button, a blank area appears, there are chances that drupal stripped the FBML tags. You need to go to Admin >> Configuration >> Content >> Formats >> Full_HTML and disable the checkbox saying 'Correct faulty and chopped off HTML '

The beauty of Social Plugins are these features work without an application that you have to maintain and that your users have to authorize.

Note: To avoid trouble with the installation, please watch this video: Using Facebook for Comments

Help improve this page

Page status: Not set

You can: