function hook_block_view

7.x block.api.php hook_block_view($delta = '')

Return a rendered or renderable view of a block.


$delta: Which block to render. This is a unique identifier for the block within the module, defined in hook_block_info().

Return value

Either an empty array so the block will not be shown or an array containing the following elements:

  • subject: The default localized title of the block. If the block does not have a default title, this should be set to NULL.
  • content: The content of the block's body. This may be a renderable array (preferable) or a string containing rendered HTML content. If the content is empty the block will not be shown.

For a detailed usage example, see block_example.module.

See also




Related topics

17 functions implement hook_block_view()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

aggregator_block_view in drupal/modules/aggregator/aggregator.module
Implements hook_block_view().
block_block_view in drupal/modules/block/block.module
Implements hook_block_view().
block_test_block_view in drupal/modules/block/tests/block_test.module
Implements hook_block_view().
blog_block_view in drupal/modules/blog/blog.module
Implements hook_block_view().
book_block_view in drupal/modules/book/book.module
Implements hook_block_view().

... See full list

1 invocation of hook_block_view()
_block_render_blocks in drupal/modules/block/block.module
Render the content and subject for a set of blocks.


drupal/modules/block/block.api.php, line 217
Hooks provided by the Block module.


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;