Add menu sub-navigation as a sidebar block in Drupal

Add menu sub-navigation as a sidebar block in Drupal

I am currently on a project that requires a 2-level drop down navigation and a sidebar block that displays the pages in the current section. This is not the first or second time I have used this recipe so it's time to share. This block can be used to display other pages in a section. drop down and subnav As we see in this image, there is a drop down menu and a block that displays the same items in the drop-down as a block on the right. nested menu Only one menu is needed. There is no need to maintain two menus or a custom block and a main menu. Here is the code for the block. It retrieves the menu as an array. If the current path you are on is a descendant of a top level menu item, the top item will have "in_active_trail" set to TRUE. We are interested only in the menu items below, so we retrieve those and theme them. No extra rules need to be added on when to display the block. The block will not display if there is no output. If you are in a path that is not in the menu, the block will not show. $mi) { if ($mi['link']['in_active_trail'] && $tree[$key]['below']) { $menu = menu_tree_output($tree[$key]['below']); } } print $menu; ?>

Related Posts

Improving Menu Views in Drupal 7 to Create Mega Menus More Efficiently

Mark Carver
Read more

How to Programmatically Create a Quicktab Block in Drupal

Dustin Currie
Read more

How to display an RSS feed in a Drupal block

Kristin Brinner
Read more

Loving the Block Revisited

Randall Knutson
Read more

How I Learned to Stop Worrying and Love the Block

Randall Knutson
Read more

Facet Block - The Unknown Hero

Kyle Taylor
Read more