D7 Render Arrays on in hook_block_view

2 replies [Last post]
Last seen: 32 weeks 10 hours ago
Joined: 2011-02-07

Drupal 7 wants you to create render arrays to make blocks. Here's the example from

function hook_block_view($delta = '') {
  // This example is adapted from node.module.
  $block = array();

  switch ($delta) {
    case 'syndicate':
      $block['subject'] = t('Syndicate');
      $block['content'] = array(
        '#theme' => 'feed_icon',
        '#url' => 'rss.xml',
        '#title' => t('Syndicate'),

    case 'recent':
      if (user_access('access content')) {
        $block['subject'] = t('Recent content');
        if ($nodes = node_get_recent(variable_get('node_recent_block_count', 10))) {
          $block['content'] = array(
            '#theme' => 'node_recent_block',
            '#nodes' => $nodes,
        else {
          $block['content'] = t('No content available.');
  return $block;
Source: <a href="http://api.drupal.org/api/drupal/modules--block--block.api.php/function/hook_block_view/7</p>
<p>Does" title="http://api.drupal.org/api/drupal/modules--block--block.api.php/function/hook_block_view/7</p>
<p>Does">http://api.drupal.org/api/drupal/modules--block--block.api.php/function/...</a> anyone know enough about these render arrays to create a block this way?


Last seen: 32 weeks 10 hours ago
Joined: 2011-02-07
Source URL for hook_block_view()
Chris Shattuck
Last seen: 6 days 1 hour ago
Joined: 2009-08-16
Hey Joe, I'm guessing you

Hey Joe,

I'm guessing you have, but just in case have you checked out the videos on doing this, starting with http://buildamodule.com/video/drupal-7-core-concepts-how-hooks-work-and-... ? There's three of them that take you through the process in succession.

Let me know if that helps or if you still run into snags.


Add to playlist

Add to , or

Add to new playlist:

Add to playlist
This is a member-only feature
But, it's easy to become a member

Add to cart:

Contact us

Below are the supported keyboard shortcuts for our video player.

Start / stop video
Go to next video
Go to previous video
Increase or decrease player speed by 20%
Skip ahead or go back by 15 seconds
Jump to a percentage (2 is 20%, for example)
Toggle full screen
Videos Pricing More Search
BuildAModule Logo Icon BuildAModule Logo Icon
Become a member!
1 month
6 months
10% off
12 months
20% off
All memberships come with the following:
24 / 7 access to the entire 1800+ video library
An innovative video player with a rolling transcript
Extensive Drupal and cross-platform training
A thorough and thoughtful training style
Progress tracking
Take notes on specific video sections
Intuitive multi-user management
How many users?
Go solo with a single user, or give multiple team members access through one account and get discounts by bundling multiple users into a single membership.