function _submenutree_block_extended_primary_links in Submenu Tree 6
Same name and namespace in other branches
- 7 submenutree.module \_submenutree_block_extended_primary_links()
Return block of extended primary links
1 call to _submenutree_block_extended_primary_links()
- submenutree_block in ./
submenutree.module - Implementation of hook_block().
File
- ./
submenutree.module, line 441
Code
function _submenutree_block_extended_primary_links() {
// Choose the appropriate menu root
$primary_name = variable_get('menu_primary_links_source', 'primary-links');
$secondary_name = variable_get('menu_secondary_links_source', 'secondary-links');
if ($primary_name) {
$menu_name = $primary_name;
if ($primary_name != $secondary_name) {
$level = 1;
}
else {
$level = 2;
}
// Select the third level of the primary menu
}
else {
if ($secondary_name) {
$menu_name = $secondary_name;
$level = 1;
// Select the second level of the secondary menu
}
else {
break;
}
}
// Loosely derived from menu_navigation_links()
$tree = menu_tree_page_data($menu_name);
// Go down the active trail until the right level is reached.
while ($level-- > 0 && $tree) {
// Loop through the current level's items until we find one that is in trail.
while ($item = array_shift($tree)) {
if ($item['link']['in_active_trail']) {
$parent = $item;
// If the item is in the active trail, we continue in the subtree.
$tree = empty($item['below']) ? array() : $item['below'];
break;
}
}
}
$title = $parent['link']['title'];
$output = menu_tree_output($tree);
if (!empty($output)) {
$block = array(
'subject' => $title,
'content' => $output,
);
return $block;
}
}