Add items to the Toolbar menu.
The Toolbar has two parts. The tabs are menu links, rendered by theme_links(), that are displayed if the module is enabled and the user has the 'access toolbar' permission. The trays are render elements, usually lists of links, and each tray corresponds to a tab. When a tab is activated, the corresponding tray is displayed; only one tab can be activated at a time. If a tab does not have a corresponding tray, or if javascript is disabled, then the tab is simply a link.
This hook is invoked in toolbar_view().
An array of toolbar items, keyed by unique identifiers such as 'home' or 'administration', or the short name of the module implementing the hook. The corresponding value is an associative array that may contain the following key-value pairs:
array with keys 'title', 'href', 'html', and 'attributes', as used by theme_links(). The 'href' value is ignored unless 'tray' (below) is omitted, or if javascript is disabled.
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
function hook_toolbar() {
$items = array();
// The 'Home' tab is a simple link, with no corresponding tray.
$items['home'] = array(
'tab' => array(
'title' => t('Home'),
'href' => '<front>',
'html' => FALSE,
'attributes' => array(
'title' => t('Home page'),
),
),
'weight' => -10,
);
/**
* A tab may be associated with a tray.
*
* The tray should contain a renderable array. An option #heading property
* can be passed. The text is written to a heading tag in the tray as a
* landmark for accessibility. A default heading will be created if one is not
* passed.
*/
$items['commerce'] = array(
'tab' => array(
'title' => t('Shopping cart'),
'href' => '',
'html' => FALSE,
'attributes' => array(
'title' => t('Shopping cart'),
),
),
'tray' => array(
'#heading' => t('Shopping cart actions'),
'content' => array(
'#theme' => 'item_list',
'#items' => array(),
),
),
'weight' => 50,
);
return $items;
}