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

Breadcrumb

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

function hook_toolbar_alter

Alter the toolbar menu after hook_toolbar() is invoked.

This hook is invoked by Toolbar::preRenderToolbar() immediately after hook_toolbar(). The toolbar definitions are passed in by reference. Each element of the $items array is one item returned by a module from hook_toolbar(). Additional items may be added, or existing items altered.

Parameters

$items: Associative array of toolbar menu definitions returned from hook_toolbar().

Related topics

Hooks
Define functions that alter the behavior of Drupal core.
1 invocation of hook_toolbar_alter()
Toolbar::preRenderToolbar in core/modules/toolbar/src/Element/Toolbar.php
Builds the Toolbar as a structured array ready for rendering.

File

core/modules/toolbar/toolbar.api.php, line 163

Code

function hook_toolbar_alter(&$items) {
    // Move the User tab to the right.
    $items['commerce']['#weight'] = 5;
}
RSS feed
Powered by Drupal