Add a "latest tweets" block integrated with Views module

Last updated on
17 August 2018

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

When you first install the Twitter module, it comes with a View that displays tweets for user pages only. The "User Tweets" block will not work except on a user page.

This step by step guide allows you to create a site-wide block that lists tweets from either a single Twitter account, or combined tweets from all twitter users on the site.

Tweets are pulled on cron run by Twitter module and the listing is managed by Views module.

Requirements

Twitter and Views modules.

Installing, configuring and enabling the block

  1. Enable views_ui and twitter modules.
  2. As the admin user, go to "My account" > Edit > Twitter accounts (user/[your user id]/edit).
  3. At "Twitter user name", type the Twitter user which you want its tweets to be listed (ie: drupal). Hit "Add account" and you should see that the account gets listed and the account image and description are visible.
  4. Run cron at admin/config/system/cron (Drupal 7) or cron.php (Drupal 6) to load tweets from the added account.
  5. Go to views at Structure ('Administration' in Drupal 6) > Views. Clone the view "tweets" to "Site tweets". Hit Continue and set the following configuration to the Block display of the new Site tweets view:
    • Block name: Site tweets.
    • Expand the "Advanced" link (in Drupal 6, it is called "Arguments") and under Contextual Filters click on User:uid
    • Make sure "This block only (override)" is selected in the dropdown and then:
    • For a block that shows ALL user tweets from this site: hit "Remove" to remove the filter.
    • For a block that shows tweets from a single user: Choose "Provide a Default Value" radio under "WHEN THE FILTER VALUE IS NOT AVAILABLE", set the "Type" to "Fixed Value". Finally, set the "Fixed Value" to 1 (or whatever uid you wish to dipslay).
    • Remove everything from, and untick, "Specify validation criteria" under "WHEN THE FILTER VALUE IS AVAILABLE OR A DEFAULT IS PROVIDED". The validation is not needed as the value you are providing is fixed.
    • Press "Apply (this display only)" to save your changes to the argument.
    • Review paging and format settings and preview with the button at the bottom until it fits what you need. Remember to always choose "This block only (override)" when changing these settings, so they don't change on the Page view too.
    • Save the view.
  6. Enable the new "Site tweets" block at Structure > blocks or Structure > contexts, or Admin > Context in Drupal 6 (if you are using Context module instead).
  7. Clear the cache.
  8. Verify that the block is displayed.
  9. Set cron to run periodically in order to pull new tweets.

Help improve this page

Page status: No known problems

You can: