You are here

function token_menu_link_load in Token 7

Same name and namespace in other branches
  1. 6 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()
token_menu_link_load_all_parents in ./token.module
token_node_menu_link_load in ./token.module
Load the preferred menu link associated with a node.
token_tokens in ./token.tokens.inc
Implements hook_tokens().
1 string reference to 'token_menu_link_load'
token_clear_cache in ./token.module
Clear token caches and static variables.

File

./token.module, line 1042
Enhances the token API in core: adds a browseable UI, missing tokens, etc.

Code

function token_menu_link_load($mlid) {
  $cache =& drupal_static(__FUNCTION__, array());
  if (!is_numeric($mlid)) {
    return FALSE;
  }
  if (!isset($cache[$mlid])) {
    $item = db_query("SELECT * FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE ml.mlid = :mlid", array(
      ':mlid' => $mlid,
    ))
      ->fetchAssoc();
    if (!empty($item)) {
      _token_menu_link_translate($item);
    }
    $cache[$mlid] = $item;
  }
  return $cache[$mlid];
}