You are here

function token_menu_link_load in Token 6

Same name and namespace in other branches
  1. 7 token.module \token_menu_link_load()

Get a translated menu link by its mlid, without access checking.

This function is a copy of menu_link_load() but with its own cache and a simpler query to load the link. This also skips normal menu link access checking by using _token_menu_link_translate().

Parameters

$mlid: The mlid of the menu item.

Return value

A menu link translated for rendering.

See also

menu_link_load()

_token_menu_link_translate()

3 calls to token_menu_link_load()
book_token_values in ./token_node.inc
Implements hook_token_values() on behalf of book.module.
menu_token_values in ./token_node.inc
Implements hook_token_values() on behalf of menu.module.
token_menu_link_get_parents_all in ./token.module
Find all ancestors of a given menu link ID.

File

./token.module, line 838
The Token API module.

Code

function token_menu_link_load($mlid) {
  static $cache = array();
  if (!is_numeric($mlid)) {
    return FALSE;
  }
  if (!isset($cache[$mlid])) {
    $item = db_fetch_array(db_query("SELECT * FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE ml.mlid = %d", $mlid));
    if (!empty($item)) {
      _token_menu_link_translate($item);
    }
    $cache[$mlid] = $item;
  }
  return $cache[$mlid];
}