Need some help with your project? Contact me

Cool modules: Menu block and Menu tag

Menu block provides your Drupal site with configurable blocks of menu trees that start from and go down to any hierarchical level you want. Menu Tag works nicely with Menu block and allows you to create tags to filter the display of individual menu items in the block.

I wanted to talk about both these modules in a single post because of the nice way they interact with each other. You can use them to create a large menu with multiple hierarchical levels and apply tags to each individual menu items. Then, you can declare multiple blocks of the same menu and select which menu items to show by selecting the appropriate tag.

Let’s however first go over how you configure these modules.

Menu block

The first thing you need to do after installing this module is go to Structure -> Blocks and add a new Menu block. Give it a title (or not) and select which menu you want this block to display. Then, you select the hierarchical level it starts from and how deep in it it should go. The rest is normal.

Now, what is to be expected of these levels? The start level will determine at which point the menu items will start showing. For instance, if you select level 2, it will start displaying the children of menu items which are on the second level of the structure if this menu item is active (if the user is viewing the page on the second level). Additionally, it will expand as the user traverses down the structure.

The maximum depth is of course the level it should stop at.

Menu Tag

With this module, you can control exactly which individual menu items get displayed in the menu block. To do this, when you create a new menu item, you assign it a tag. Then in the menu block, you enter the tag filter you want. So if you have a big menu structure, you can create multiple blocks and choose which items to show in each. Pretty nifty no?

Note: you can only choose by which tag the block menu should filter after the block was created. In other words, when you create a new Menu block, you won’t be able to already select the tag. You have to save and then go back to its configuration.

OK, so you get the idea, I’ll let you go ahead and try these cool modules for yourselves. If you run into any problems, feel free to drop a comment.

Add new comment

You can post comments in Markdown and basic HTML tags.
For code blocks, wrap your code within '~~~'. For example:
$var = 'my variable';