1 block_example.module block_example_block_info()

Implements hook_block_info().

This hook declares what blocks are provided by the module.

Related topics


modules/examples/block_example/block_example.module, line 47
Module file for block_example.


function block_example_block_info() {
  // This hook returns an array, each component of which is an array of block
  // information. The array keys are the 'delta' values used in other block
  // hooks.
  // The required block information is a block description, which is shown
  // to the site administrator in the list of possible blocks. You can also
  // provide initial settings for block weight, status, etc.
  // Many options are defined in hook_block_info():
  $blocks['example_configurable_text'] = array(
    // info: The name of the block.
    'info' => t('Example: configurable text string'),
    'description' => 'This is block is configurable.',

  // This sample shows how to provide a block which extends Block class. The
  // configuration and display of this block are defined in a separate class
  // file which is loaded by hook_autoload_info().
  $blocks['example_subclass'] = array(
    'info' => t('Example: subclass block'),
    'description' => 'This block is defined by extending Block class.',
    'class' => 'BlockExample',

  $blocks['example_uppercase'] = array(
    // info: The name of the block.
    'info' => t('Example: uppercase this please'),
    'description' => 'This block\'s title will be uppercase.',

  // This sample shows how to make a block that is only available when required
  // information is provided. This block will only be available when it is
  // placed in a layout that has a node context. That is, the layout's path
  // is node/% or any other path where the wildcard is a node ID.
  $blocks['example_node_context'] = array(
    'info' => t('Example: Node Context'),
    'description' => t('This block is only available when a node context is available. It will pull out information about the node and display it in the block.'),
    // The key of this array is the name of the context and the value is the
    // type of context. This allows you to require multiple contexts of the same
    // type. e.g. array('node1' => 'node', 'node2' => 'node').
    'required contexts' => array('node' => 'node'),

  return $blocks;