function hook_menu_contextual_links_alter
hook_menu_contextual_links_alter(&$links, $router_item, $root_path)
Alter contextual links before they are rendered.
This hook is invoked by menu_contextual_links(). The system-determined contextual links are passed in by reference. Additional links may be added or existing links can be altered.
Each contextual link must at least contain:
- title: The localized title of the link.
- href: The system path to link to.
- localized_options: An array of options to pass to url().
Parameters
$links: An associative array containing contextual links for the given $root_path, as described above. The array keys are used to build CSS class names for contextual links and must therefore be unique for each set of contextual links.
$router_item: The menu router item belonging to the $root_path being requested.
$root_path: The (parent) path that has been requested to build contextual links for. This is a normalized path, which means that an originally passed path of 'node/123' became 'node/%'.
See also
hook_contextual_links_view_alter()
Related topics
File
- modules/system/system.api.php, line 1561
- Hooks provided by Drupal core and the System module.
Code
function hook_menu_contextual_links_alter(&$links, $router_item, $root_path) { // Add a link to all contextual links for nodes. if ($root_path == 'node/%') { $links['foo'] = array( 'title' => t('Do fu'), 'href' => 'foo/do', 'localized_options' => array( 'query' => array( 'foo' => 'bar', ), ), ); } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_menu_contextual_links_alter/7.x