1 menu.tokens.inc _menu_token_link_load_all_parents($mlid)

Load all menu parents given a Menu Link ID.

Parameters

int $mlid: Menu Link ID.

Return value

array: Array of link titles keyed by menu link ID.

File

core/modules/menu/menu.tokens.inc, line 235
Builds placeholder replacement tokens for menu-related data.

Code

function _menu_token_link_load_all_parents($mlid) {
  $cache = &backdrop_static(__FUNCTION__, array());

  if (!is_numeric($mlid)) {
    return array();
  }

  if (!isset($cache[$mlid])) {
    $cache[$mlid] = array();
    $plid = db_query("SELECT plid FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $mlid))->fetchField();
    while ($plid && $parent = _menu_token_link_load($plid)) {
      $cache[$mlid] = array($plid => $parent['title']) + $cache[$mlid];
      $plid = $parent['plid'];
    }
  }

  return $cache[$mlid];
}