I want to display the sub menus of the currently accessing primary link as a block. Drupal provides Primary links, Secondary links blocks but does not display sub menus of currently accessing primary link.
When I search, I got following code snippet which lists the sub menus of currently accessing primary link. I directly created block using Add block by adding this php code snippet. It works a charm.
$tree = menu_tree_page_data('primary-links'); //substitute your menu name for primary-links
foreach($tree as $key => $mi) {
if ($mi['link']['in_active_trail'] && $tree[$key]['below']) {
$menu = menu_tree_output($tree[$key]['below']);
}
}
print $menu;
I hope this will help others to find easily.