Is it possible to setup Facebook block for each user? When a user registers or later in specific node he can copy/paste a link in text field that will result in his Facebook page block.

I know how to setup views contextual to show block for each user based on user's id or nid, so that part is covered.

2 Answers 2


I'm presuming you want to do something like a Facebook Likebox embedded iframe (e.g. https://www.facebook.com/plugins/likebox.php?my_user_facebook_page_details...) with the user supplying his own URL in his user account profile.

If that's the case set up your block view to render your user's URL field with a custom template. Under the Views UI in Advanced > Other > Theme, the Information link will give you a list of template names (e.g. views-view-field--field-my_user_field.tpl.php) that you can put in your theme's template directory and some boilerplate code (found via the link next to the template names). You can alter the template such that the $output is wrapped in a iframe src attribute.

Flushing the cache should rebuild everything so that your block's URL field now renders as an iframe on the user page (if you've configured your contextual filter correctly). It probably should be noted that rendering a user-supplied iframe URL is dangerous so you probably should be filtering out non-Facebook URLs.


Here are the steps that I think should help to create such block:

  • Define an appropriate text field containing the link within the user profile, and make it optional.
  • Use the Views module to create a list of users.
  • Format the view as a block (not as a page).
  • The only field to be shown is your text field containing the link.
  • Add a contextual filter to limit the results to the uid of the currently logged in user.
  • Since there should only be 1 record selected, there is no need for any sorting.
  • Place the block wherever it fits on your page(s).
  • If needed, adapt the block visibility settings to fit your needs. Optionally use the Rules Block Visibility module to refine the logic about when to yes/no display the block (eg: if the profile field is empty, then don't show the block).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.