Embedded Twitter feed in Drupal 7 using the Twitter Pull module

There are many Twitter modules for Drupal out there and I've gone through them all. Twitter pull does the job perfectly. It's not a surprise to anyone how huge social media is nowadays. If you have a website you should have some degree of social media integration, be it a simple link to your Twitter, Facebook or LinkedIn profiles, or a full blown embedded feed of your posts and tweets. A lot of clients these days are requesting embedded Twitter feeds, much like the one we employ in our footer. Below are the steps needed to add a twitter feed to your Drupal 7 website.

  1. First, download and install the Twitter Pull module.
  2. Next, create a custom block using the hook_block_info & hook_block_view functions. We'll use twitter pull's built in function to display the contents of the feed.
    /*
     * Implements hook_block_info()
     *
    */
    function deckfifty_block_info() {
      $blocks['twitter_pull'] = array(
        'info' => t('Twitter Pull'),
      );
    
      return $blocks;
    }
    
    /*
     * Implements hook_block_view()
     *
    */
    function deckfifty_block_view($delta) {
      $block = array();
    
      switch ($delta) {
        case 'twitter_pull':
          $block['subject'] = t('Twitter Feed');
          $block['content'] = twitter_pull_render('@deckfifty', '', 3); // swap out @deckfifty with your twitter handle, and 3 with the number of posts you want to display
          break;
      }
    
      return $block;
    }
    
  3. In order to modify the the block content specifically, we'll alter the template file that comes with twitter pull (twitter-pull-listing.tpl.php) and place it in our theme directory
  4. Finally, go to the blocks section and enable the block.

That's all you need. You can now proceed to theme the block output in css, and watch your tweets roll in!