function menu_CrumbsMultiPlugin_hierarchy::findParent in Crumbs, the Breadcrumbs suite 7
Same name and namespace in other branches
- 7.2 plugins/crumbs.menu.inc \menu_CrumbsMultiPlugin_hierarchy::findParent()
File
- plugins/
crumbs.menu.inc, line 23
Class
Code
function findParent($path, $item) {
$q = db_select('menu_links', 'parent');
$q
->innerJoin('menu_links', 'child', 'parent.mlid = child.plid');
$q
->addExpression('parent.link_path', 'parent_path');
$q
->addExpression('parent.menu_name', 'menu_name');
$q
->condition('child.link_path', $path);
// Top-level links have higher priority.
$q
->orderBy('parent.depth', 'ASC');
// Ignore placeholder or separator menu items added by special_menu_items.
$q
->condition('parent.link_path', array(
'<nolink>',
'<separator>',
), 'NOT IN');
// Collect candidates for the parent path, keyed by menu name.
$candidates = array();
foreach ($q
->execute() as $row) {
if (!isset($candidates[$row->menu_name])) {
$candidates[$row->menu_name] = $row->parent_path;
}
}
return $candidates;
}