function hook_block_info in MongoDB 7
Define all blocks provided by the module.
This hook declares to Drupal what blocks are provided by your module and can optionally specify initial block configuration settings.
Return value
array An associative array whose keys define the delta for each block and whose values contain the block descriptions. Each block description is itself an associative array, with the following key-value pairs:
- cache: (optional) A bitmask describing what kind of caching is
appropriate for the block. Drupal provides the following bitmask
constants for defining cache granularity:
- DRUPAL_CACHE_PER_ROLE (default): The block can change depending on the roles the user viewing the page belongs to.
- DRUPAL_CACHE_PER_USER: The block can change depending on the user viewing the page. This setting can be resource-consuming for sites with large number of users, and should only be used when DRUPAL_CACHE_PER_ROLE is not sufficient.
- DRUPAL_CACHE_PER_PAGE: The block can change depending on the page being viewed.
- DRUPAL_CACHE_GLOBAL: The block is the same for every user on every page where it is visible.
- DRUPAL_CACHE_CUSTOM: The module implements its own caching system.
- DRUPAL_NO_CACHE: The block should not get cached.
- weight: (optional) Initial value for the ordering weight of this block. Most modules do not provide an initial value, and any value provided can be modified by a user on the block configuration screen.
- status: (optional) Initial value for block enabled status. (1 = enabled, 0 = disabled). Most modules do not provide an initial value, and any value provided can be modified by a user on the block configuration screen.
- region: (optional) Initial value for theme region within which this block is set. Most modules do not provide an initial value, and any value provided can be modified by a user on the block configuration screen. Note: If you set a region that isn't available in the currently enabled theme, the block will be disabled.
- 'pages': an array of menu paths where the block should appear. Example: array('admin', 'node/%/edit') will display the block on admin, admin/structure etc. and the node edit pages.
- 'node_type': List of node types. The block will appear only on node/% pages with the specified node types.
1 function implements hook_block_info()
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_info in mongodb_block_ui/
mongodb_block_ui.module - Implements hook_block_info().
3 invocations of hook_block_info()
- mongodb_block_ui_add_block_form_validate in mongodb_block_ui/
mongodb_block_ui.admin.inc - Form validation handler for mongodb_block_ui_add_block_form.
- mongodb_block_ui_admin_configure in mongodb_block_ui/
mongodb_block_ui.admin.inc - Menu callback; displays the mongodb_block_ui configuration form.
- _mongodb_block_rehash in mongodb_block/
mongodb_block.module - Updates the block collection with the blocks currently exported by modules.
File
- mongodb_block/
mongodb_block.api.php, line 56 - Hooks provided by the Block module.
Code
function hook_block_info() {
$blocks['exciting'] = array(
'info' => t('An exciting block provided by Mymodule.'),
'weight' => 0,
'status' => 1,
'region' => 'sidebar_first',
);
$blocks['amazing'] = array(
'info' => t('An amazing block provided by Mymodule.'),
'cache' => DRUPAL_CACHE_PER_ROLE | DRUPAL_CACHE_PER_PAGE,
);
return $blocks;
}