function hook_menu_get_item_alter
hook_menu_get_item_alter(&$router_item, $path, $original_map)
Alter a menu router item right after it has been retrieved from the database or cache.
This hook is invoked by menu_get_item() and allows for run-time alteration of router information (page_callback, title, and so on) before it is translated and checked for access. The passed-in $router_item is statically cached for the current request, so this hook is only invoked once for any router item that is retrieved via menu_get_item().
Usually, modules will only want to inspect the router item and conditionally perform other actions (such as preparing a state for the current request). Note that this hook is invoked for any router item that is retrieved by menu_get_item(), which may or may not be called on the path itself, so implementations should check the $path parameter if the alteration should fire for the current request only.
Parameters
$router_item: The menu router item for $path.
$path: The originally passed path, for which $router_item is responsible.
$original_map: The path argument map, as contained in $path.
See also
Related topics
File
- modules/system/system.api.php, line 940
- Hooks provided by Drupal core and the System module.
Code
function hook_menu_get_item_alter(&$router_item, $path, $original_map) { // When retrieving the router item for the current path... if ($path == $_GET['q']) { // ...call a function that prepares something for this request. mymodule_prepare_something(); } }
© 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_get_item_alter/7.x