function hook_block_view

×

Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
cis7 block.api.php hook_block_view($delta = '')
cle7 block.api.php hook_block_view($delta = '')
elmsmedia7 block.api.php hook_block_view($delta = '')
icor7 block.api.php hook_block_view($delta = '')
meedjum_blog7 block.api.php hook_block_view($delta = '')
mooc7 block.api.php hook_block_view($delta = '')

Return a rendered or renderable view of a block.

Parameters

$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

hook_block_info()

hook_block_view_alter()

hook_block_view_MODULE_DELTA_alter()

Related topics

31 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 modules/aggregator/aggregator.module
Implements hook_block_view().
block_block_view in modules/block/block.module
Implements hook_block_view().
block_test_block_view in modules/block/tests/block_test.module
Implements hook_block_view().
blog_block_view in modules/blog/blog.module
Implements hook_block_view().
book_block_view in modules/book/book.module
Implements hook_block_view().

... See full list

5 invocations of hook_block_view()
context_reaction_block::is_editable_check in sites/all/modules/ulmus/context/plugins/context_reaction_block.inc
Determine if there is an active context editor block, and set a flag. We will set a flag so that we can make sure that blocks with empty content have some default content. This is needed so the save of the context inline editor does not remove theā€¦
ctools_block_content_type_admin_info in sites/all/modules/ulmus/ctools/plugins/content_types/block/block.inc
Output function for the 'block' content type. Outputs a block based on the module and delta supplied in the configuration.
ctools_block_content_type_render in sites/all/modules/ulmus/ctools/plugins/content_types/block/block.inc
Output function for the 'block' content type. Outputs a block based on the module and delta supplied in the configuration.
ds_render_block_field in sites/all/modules/ulmus/ds/ds.module
Render a block field.
_block_render_blocks in modules/block/block.module
Render the content and subject for a set of blocks.

File

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

Code

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'),
      );
      break;

    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.');
        }
      }
      break;
  }
  return $block;
}