hook_block_view_BASE_BLOCK_ID_alter

hook_block_view_BASE_BLOCK_ID_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block)

Provide a block plugin specific block_view alteration.

In this hook name, BASE_BLOCK_ID refers to the block implementation's plugin id, regardless of whether the plugin supports derivatives. For example, for the \Drupal\system\Plugin\Block\SystemPoweredByBlock block, this would be 'system_powered_by_block' as per that class's annotation. And for the \Drupal\system\Plugin\Block\SystemMenuBlock block, it would be 'system_menu_block' as per that class's annotation, regardless of which menu the derived block is for.

Parameters

array $build: A renderable array of data, as returned from the build() implementation of the plugin that defined the block:

  • #title: The default localized title of the block.

\Drupal\Core\Block\BlockPluginInterface $block: The block plugin instance.

See also

hook_block_view_alter()

Entity CRUD, editing, and view hooks

Related topics

Block API
Information about the classes and interfaces that make up the Block API.
Hooks
Define functions that alter the behavior of Drupal core.

File

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

Code

function hook_block_view_BASE_BLOCK_ID_alter(array &$build, \Drupal\Core\Block\BlockPluginInterface $block) {
  // Change the title of the specific block.
  $build['#title'] = t('New title of the block');
}
doc_Drupal
2016-10-29 09:17:51
Comments
Leave a Comment

Please login to continue.