A three level menu:
Item 1
Item A
Item X
Item Y
Item Z
Item B
Item Xx
Item Yx
Item Zx
Item C
Item Xy
When viewing the "Item 1" node, I'd like to display the sub-menu items in the template: Item A, Item B, Item C
When viewing the "Item B" node, I'd like to display the sub-menu items in the template: Item Xx, Item Yx, Item Zx
While I would like to rely totally on the menu structure, the output will not be displayed as a traditional menu.
This code does what I need:
function subpages($nid=null) {
$nid = 'node/'.$nid;
$menuItems = menu_tree_page_data('main-menu');
foreach($menuItems as $key => $m) {
if ($m['link']['in_active_trail'] && $menuItems[$key]['below'] && $m['link']['link_path'] == $nid) {
$menu = menu_tree_output($menuItems [$key]['below']);
} else if ($m['link']['in_active_trail'] && count($menuItems[$key]['below']) > 0) {
foreach ($menuItems[$key]['below'] as $k => $third) {
if ($third['below'] && $third['link']['in_active_trail']) {
$menu = menu_tree_output($third['below']);
//foreach ($third['below'] as $item) {
// echo $item['link']['link_title'].'<br>';
//}
}
}
}
}
return $menu;
}