You are here

function hook_block_view in MongoDB 7

Return a rendered or renderable view of a block.

The functions mymodule_display_block_exciting and _amazing, as used in the example, should of course be defined somewhere in your module and return the content you want to display to your users. If the "content" element is empty, no block will be displayed even if "subject" is present.

For a detailed usage example, see block_example.module.

Parameters

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

Return value

array 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.

See also

hook_block_info()

hook_block_view_alter()

hook_block_view_MODULE_DELTA_alter()

1 function implements 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.

mongodb_block_ui_block_view in mongodb_block_ui/mongodb_block_ui.module
Implements hook_block_view().
1 invocation of hook_block_view()
mongodb_block_render_blocks in mongodb_block/mongodb_block.module
Render the content and subject for a set of blocks.

File

mongodb_block/mongodb_block.api.php, line 117
Hooks provided by the Block module.

Code

function hook_block_view($delta = '') {
  switch ($delta) {
    case 'exciting':
      $block = array(
        'subject' => t('Default title of the exciting block'),
        'content' => mymodule_display_block_exciting(),
      );
      break;
    case 'amazing':
      $block = array(
        'subject' => t('Default title of the amazing block'),
        'content' => mymodule_display_block_amazing(),
      );
      break;
  }
  return $block;
}