1 menu.inc menu_link_load($mlid, $skip_access_check = FALSE)

Gets a translated menu link that is ready for rendering.

This function should never be called from within node_load() or any other function used as a menu object load function since an infinite recursion may occur.

Parameters

int $mlid: The mlid of the menu item.

bool $skip_access_check: If set to TRUE, the menu link access checks will not be performed. If set to FALSE, access checks are performed and $item['access'] will be populated with the current user's access to the menu item.

Return value

A menu link, with $item['access'] filled and link translated for: rendering.

Related topics

File

core/includes/menu.inc, line 2834
API for the Backdrop menu system.

Code

function menu_link_load($mlid, $skip_access_check = FALSE) {
  if (is_numeric($mlid)) {
    $query = db_select('menu_links', 'ml');
    $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
    $query->fields('ml');
    // Weight should be taken from {menu_links}, not {menu_router}.
    $query->addField('ml', 'weight', 'link_weight');
    $query->fields('m');
    $query->condition('ml.mlid', $mlid);
    if ($item = $query->execute()->fetchAssoc()) {
      $item['weight'] = $item['link_weight'];
      if ($skip_access_check) {
        $item['access'] = TRUE;
      }
      _menu_link_translate($item);
      return $item;
    }
  }
  return FALSE;
}