You are here

function menu_get_item in Drupal 6

Same name and namespace in other branches
  1. 4 includes/menu.inc \menu_get_item()
  2. 5 includes/menu.inc \menu_get_item()
  3. 7 includes/menu.inc \menu_get_item()

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 will be filled in based on the database values and the objects loaded.

Related topics

14 calls to menu_get_item()
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_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) for a given level.
menu_reset_item in modules/menu/menu.module
Reset a system-defined menu item.

... See full list

File

includes/menu.inc, line 304
API for the Drupal menu system.

Code

function menu_get_item($path = NULL, $router_item = NULL) {
  static $router_items;
  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);
    list($ancestors, $placeholders) = menu_get_ancestors($parts);
    if ($router_item = db_fetch_array(db_query_range('SELECT * FROM {menu_router} WHERE path IN (' . implode(',', $placeholders) . ') ORDER BY fit DESC', $ancestors, 0, 1))) {
      $map = _menu_translate($router_item, $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_items[$path] = $router_item;
  }
  return $router_items[$path];
}