1. drupal
    1. 5
    2. 6
    3. 7
    4. 8
5 menu_get_item($mid, $path = NULL, $reset = FALSE)
6 – 8 menu_get_item($path = NULL, $router_item = NULL)

Get a router item.


$path The path, for example node/5. The function will find the corresponding node/% item and return that.

$router_item Internal use only.

Return value

The router item, an associate array corresponding to one row in the menu_router table. The value of key map holds the loaded objects. The value of key access is TRUE if the current user can access this page. The values for key title, page_arguments, access_arguments, and theme_arguments will be filled in based on the database values and the objects loaded.

Related topics

▾ 31 functions call menu_get_item()

block_page_build in modules/block/block.module
Implements hook_page_build().
blog_menu_local_tasks_alter in modules/blog/blog.module
Implements hook_menu_local_tasks_alter().
dashboard_is_visible in modules/dashboard/dashboard.module
Determines if the dashboard should be displayed on the current page.
drupal_deliver_page in includes/
Delivers a page callback result to the browser in the appropriate format.
drupal_retrieve_form in includes/
Retrieves the structured array that defines a given form.
drupal_valid_path in includes/
Checks a path exists and the current user has access to it.
MenuRouterTestCase::testMenuSetItem in modules/simpletest/tests/menu.test
Test menu_set_item().
menu_contextual_links in includes/
Retrieve contextual links for a system object based on registered local tasks.
menu_execute_active_handler in includes/
Execute the page callback associated with the current path.
menu_get_active_breadcrumb in includes/
Get the breadcrumb for the current page, as determined by the active trail.
menu_get_custom_theme in includes/
Gets the custom theme for the current page, if there is one.
menu_get_object in includes/
Get a loaded object from a router item.
menu_link_get_preferred in includes/
Lookup the preferred menu link for a given system path.
menu_local_tasks in includes/
Collects the local tasks (tabs), action links, and the root path.
menu_navigation_links in includes/
Return an array of links for a navigation menu.
menu_set_active_trail in includes/
Sets the active trail (path to menu tree root) of the current page.
menu_set_item in includes/
Replaces the statically cached item for a given path.
menu_tree_output in includes/
Returns a rendered menu tree.
menu_tree_page_data in includes/
Get the data structure representing a named menu tree, based on the current page.
node_add_page in modules/node/
node_menu_local_tasks_alter in modules/node/node.module
Implements hook_menu_local_tasks_alter().
shortcut_link_add_inline in modules/shortcut/
Menu page callback: creates a new link in the provided shortcut set.
shortcut_preprocess_page in modules/shortcut/shortcut.module
Implements hook_preprocess_page().
shortcut_valid_link in modules/shortcut/shortcut.module
Determines if a path corresponds to a valid shortcut link.
system_admin_menu_block in modules/system/system.module
Provide a single block on the administration overview page.
system_admin_menu_block_page in modules/system/
Provide a single block from the administration menu as a page.
system_get_module_admin_tasks in modules/system/system.module
Generate a list of tasks offered by a specified module.
system_modules in modules/system/
Menu callback; provides module enable/disable interface.
system_settings_overview in modules/system/
Menu callback; displays a module's settings page.
system_test_page_build in modules/simpletest/tests/system_test.module
Implements hook_page_build().
_menu_link_translate in includes/
This function is similar to _menu_translate() but does link-specific preparation such as always calling to_arg functions


includes/, line 425

function menu_get_item($path = NULL, $router_item = NULL) {
  $router_items = &drupal_static(__FUNCTION__);
  if (!isset($path)) {
    $path = $_GET['q'];
  if (isset($router_item)) {
    $router_items[$path] = $router_item;
  if (!isset($router_items[$path])) {
    // Rebuild if we know it's needed, or if the menu masks are missing which
    // occurs rarely, likely due to a race condition of multiple rebuilds.
    if (variable_get('menu_rebuild_needed', FALSE) || !variable_get('menu_masks', array())) {
    $original_map = arg(NULL, $path);

    // Since there is no limit to the length of $path, use a hash to keep it
    // short yet unique.
    $cid = 'menu_item:' . hash('sha256', $path);
    if ($cached = cache_get($cid, 'cache_menu')) {
      $router_item = $cached->data;
    else {
      $parts = array_slice($original_map, 0, MENU_MAX_PARTS);
      $ancestors = menu_get_ancestors($parts);
      $router_item = db_query_range('SELECT * FROM {menu_router} WHERE path IN (:ancestors) ORDER BY fit DESC', 0, 1, array(':ancestors' => $ancestors))->fetchAssoc();
      cache_set($cid, $router_item, 'cache_menu');
    if ($router_item) {
      // Allow modules to alter the router item before it is translated and
      // checked for access.
      drupal_alter('menu_get_item', $router_item, $path, $original_map);

      $map = _menu_translate($router_item, $original_map);
      $router_item['original_map'] = $original_map;
      if ($map === FALSE) {
        $router_items[$path] = FALSE;
        return FALSE;
      if ($router_item['access']) {
        $router_item['map'] = $map;
        $router_item['page_arguments'] = array_merge(menu_unserialize($router_item['page_arguments'], $map), array_slice($map, $router_item['number_parts']));
        $router_item['theme_arguments'] = array_merge(menu_unserialize($router_item['theme_arguments'], $map), array_slice($map, $router_item['number_parts']));
    $router_items[$path] = $router_item;
  return $router_items[$path];