Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. block.api.php

function hook_block_alter

Allow modules to alter the block plugin definitions.

Parameters

array[] $definitions: The array of block definitions, keyed by plugin ID.

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.
2 functions implement hook_block_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

olivero_theme_suggestions_block_alter in core/themes/olivero/olivero.theme
Implements hook_theme_suggestions_HOOK_alter() for block().
umami_theme_suggestions_block_alter in core/profiles/demo_umami/themes/umami/umami.theme
Implements hook_theme_suggestions_HOOK_alter() for block templates.

File

core/modules/block/block.api.php, line 255

Code

function hook_block_alter(&$definitions) {
    foreach ($definitions as $id => $definition) {
        if (str_starts_with($id, 'system_menu_block:')) {
            // Replace $definition properties: id, deriver, class, provider to ones
            // provided by this custom module.
        }
    }
}
RSS feed
Powered by Drupal