function hs_menu_hierarchical_select_lineage in Hierarchical Select 7.3
Same name and namespace in other branches
- 5.3 modules/hs_menu.module \hs_menu_hierarchical_select_lineage()
- 6.3 modules/hs_menu.module \hs_menu_hierarchical_select_lineage()
Implements hook_hierarchical_select_lineage().
File
- modules/
hs_menu.module, line 179 - Implementation of the Hierarchical Select API for the Menu module.
Code
function hs_menu_hierarchical_select_lineage($item, $params) {
$lineage = array(
$item,
);
list($menu_name, $mlid) = explode(':', $item);
// If the initial mlid is zero, then this is the root level, so we don't
// have to get the lineage.
if ($mlid > 0) {
// Prepend each parent mlid (i.e. plid) to the lineage.
do {
$plid = db_query("SELECT plid FROM {menu_links} WHERE mlid = :mlid", array(
':mlid' => $mlid,
))
->fetchField();
array_unshift($lineage, "{$menu_name}:{$plid}");
if ($mlid == $plid) {
// Somehow we have an infinite loop situation. Bail out of the loop.
break;
}
$mlid = $plid;
} while ($plid > 0);
}
return $lineage;
}