Alter tabs and actions displayed on the page before they are rendered.
This hook is invoked by menu_local_tasks(). The system-determined tabs and actions are passed in by reference. Additional tabs or actions may be added, or existing items altered.
Each tab or action is an associative array containing:
$data: An associative array containing:
$router_item: The menu system router item of the page.
$root_path: The path to the root item for this set of tabs.
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
function hook_menu_local_tasks_alter(&$data, $router_item, $root_path) {
// Add an action linking to node/add to all pages.
$data['actions']['output'][] = array(
'#theme' => 'menu_local_task',
'#link' => array(
'title' => t('Add new content'),
'href' => 'node/add',
'localized_options' => array(
'attributes' => array(
'title' => t('Add new content'),
),
),
),
);
// Add a tab linking to node/add to all pages.
$data['tabs'][0]['output'][] = array(
'#theme' => 'menu_local_task',
'#link' => array(
'title' => t('Example tab'),
'href' => 'node/add',
'localized_options' => array(
'attributes' => array(
'title' => t('Add new content'),
),
),
),
// Define whether this link is active. This can be omitted for
// implementations that add links to pages outside of the current page
// context.
'#active' => $router_item['path'] == $root_path,
);
}