1 layout.api.php hook_block_view_MODULE_DELTA_alter(&$data, $block)

Perform alterations to a specific block.

Modules can implement hook_block_view_MODULE_DELTA_alter() to modify a specific block, rather than implementing hook_block_view_alter().

Parameters

$data: The data as returned from the hook_block_view() implementation of the module that defined the block. This could be an empty array or NULL value (if the block is empty) or an array containing:

  • title: The localized title of the block.
  • content: Either a string or a renderable array representing the content of the block. You should check that the content is an array before trying to modify parts of the renderable structure.

$block: The block object, as loaded from the database, having the main properties:

  • module: The name of the module that defined the block.
  • delta: The unique identifier for the block within that module, as defined in hook_block_info().
  • settings: An array containing all block settings as defined for this instance of the block.
  • contexts: An array containing all layout contexts available for the layout.

See also

hook_block_view_alter()

hook_block_view()

Related topics

File

core/modules/layout/layout.api.php, line 768
Describe hooks provided by the Layout module.

Code

function hook_block_view_MODULE_DELTA_alter(&$data, $block) {
  // This code will only run for a specific block. For example, if MODULE_DELTA
  // in the function definition above is set to "my_module_some_delta", the code
  // will only run on the "some_delta" block provided by the "my_module" module.
  //
  // Change the title of the "some_delta" block provided by the "my_module"
  // module.
  $data['title'] = t('New title of the block');
}