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

AttachmentSize
input-format-2.png14.36 KB

Comments

Hadi Farnoud’s picture

how about comments?

jefbak2’s picture

Say I have a video content type that I want to add facebook comments to. What are the basics to implement that. Also I might need to tweak the css for the comment text color and so on, how can I override facebooks css?

Rosamunda’s picture

What if you want FB users to be able to post comments without generating a user inside your site?
Is that doable?

Thelonious Fonk’s picture

Hi,

In my Drupal 7 install, when I write <fb:like></fb:like> in the body of a page (with Full HTML format) and I then view it, it just shows a blank page (i.e. no FB Like button appears), any clue?

fb.module is installed and active.

Any help would be much appreciated.

Thanks!

Thelonious Fonk’s picture

Just had to disable Correct faulty and chopped off HTML filter in Full HTML format

UglyKidJoe’s picture

Man, thank you for posting your solution :)

You probably saved me hours of headache. My "Like" button appears now. good work

Vengeance66’s picture

I tried the fb activity block, but it's blank! I double checked everything...

So, It's full html

It's still not working... :/

Help?

Also, is there a chance to put facebook social plugin, a comment block?

Thanks!