menu_get_item

Versions
4.7 – 5
menu_get_item($mid, $path = NULL, $reset = FALSE)
6 – 7
menu_get_item($path = NULL, $router_item = NULL)

Get a router item.

Parameters

$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

▾ 22 functions call menu_get_item()

block_page_build in modules/block/block.module
Implement hook_page_build().
dashboard_is_visible in modules/dashboard/dashboard.module
Returns TRUE if the user is currently viewing the dashboard.
drupal_build_form in includes/form.inc
Build and process a form based on a form id.
drupal_deliver_page in includes/common.inc
Deliver a page callback result to the browser in the format appropriate.
menu_contextual_links in includes/menu.inc
Retrieve contextual links for a system object based on registered local tasks.
menu_execute_active_handler in includes/menu.inc
Execute the page callback associated with the current path.
menu_get_active_breadcrumb in includes/menu.inc
Get the breadcrumb for the current page, as determined by the active trail.
menu_get_custom_theme in includes/menu.inc
Gets the custom theme for the current page, if there is one.
menu_get_object in includes/menu.inc
Get a loaded object from a router item.
menu_local_tasks in includes/menu.inc
Collects the local tasks (tabs), action links, and the root path.
menu_reset_item in modules/menu/menu.module
Reset a system-defined menu item.
menu_set_active_trail in includes/menu.inc
Sets or gets the active trail (path to root menu root) of the current page.
menu_set_item in includes/menu.inc
Replaces the statically cached item for a given path.
menu_tree_page_data in includes/menu.inc
Get the data structure representing a named menu tree, based on the current page.
menu_valid_path in includes/menu.inc
Validates the path of a menu link being created or edited.
node_add_page in modules/node/node.pages.inc
path_admin_form_validate in modules/path/path.admin.inc
Verify that a URL alias is valid
shortcut_valid_link in modules/shortcut/shortcut.module
Determines if a path corresponds to a valid shortcut link.
system_admin_menu_block_page in modules/system/system.admin.inc
Provide a single block from the administration menu as a page. This function is often a destination for these blocks. For example, 'admin/structure/types' needs to have a destination to be valid in the Drupal menu system, but too much...
system_modules in modules/system/system.admin.inc
Menu callback; provides module enable/disable interface.
system_settings_overview in modules/system/system.admin.inc
Menu callback; displays a module's settings page.
system_test_page_build in modules/simpletest/tests/system_test.module
Implement hook_page_build().

Code

includes/menu.inc, line 393

<?php
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])) {
    $original_map = arg(NULL, $path);
    $parts = array_slice($original_map, 0, MENU_MAX_PARTS);
    $ancestors = menu_get_ancestors($parts);
    $router_item = db_select('menu_router')
      ->fields('menu_router')
      ->condition('path', $ancestors, 'IN')
      ->orderBy('fit', 'DESC')
      ->range(0, 1)
      ->addTag('menu_get_item')
      ->execute()->fetchAssoc();
    if ($router_item) {
      $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];
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.