Joomla menus allow you to create different levels. This is essential for creating any kind of sub-menu such as a dropdown menu.
Sometimes it's necessary to show only one or two levels from the menu. For example, you may show the top level links in the main navigation and sub-links in a sidebar navigation.
In this post, we'll show you how to display only specific menu levels in a sidebar module.
The menu items structure
Here's an example of my Main Menu menu items structure with three different levels:
- Level 1 A
- Level 2 A
- Level 3 A
- Level 3 B
- Level 3 C
- Level 2 B
- Level 2 C
- Level 2 A
- Level 1 B
- Level 1 C
Let's see if we display our menu item levels selectively.
Step #1. Display the menu items with a sidebar module
Joomla displays menu items in modules by the Menu type. If you have not created such a module, let's do it together.
- Go to Extensions > Modules > New > Menu.
- Give your new menu module a title. For my demonstration, I called my module Menu Levels.
- Assign a valid module position. I selected the Protostar's position-7.
- In the Select Menu option, choose the menu that contains your menu items. For my demonstration, I selected the Main Menu you have seen in the previous step.
- Click Save.
- Here's how our menu module looks by default:
- Let's take a look at the result when the menu is published. As you can see, all the three levels links are showing:
Let's learn how to display our three levels of Joomla menu items selectively, at will.
Step #2. Display only second level menu items
Let's assume, you would like to display the only Level 2 menu items in your module.
- Set the Start Level to 2.
- Set the End Level to 2.
- Click Save.
- Check the result. You will see that now your Joomla sidebar module will display the only Level 2 menu items.
Excellent! You now know how to set a Joomla menu module to display only level 2 menu items.
Will it work for our Level 3? Let's find out.
Step #3. Display only third level menu items
- Click Select.
- You will see the Select or Change Menu Item modal box. Click on any of your level 3 menu items. For my demonstration, I clicked Level 3 B, as you can see on the image below:
- Set the Star Level to 3.
- Set the End Level to 3.
- Click Save.
- Go to your site front end and check the result. You will see that your menu module now displays only Level 3 menu items:
This will be the result:
Good job! You are now able to explicitly display your Joomla menu levels in a Joomla sidebar module.
Let's learn how to display our levels in combination.
Step #4. Display both second and third level menu items
Let's show menu items belonging to Level 2 and Level 3.
- Go to the Base Item parameter and click Clear:
- The parameter will then display Current:
- Click Select and then select Level 2 A menu item.
- Set the Start Level to 2.
- Set the End Level to 3.
- Click Save.
- Check the result:
What's Next?
What's Next?
Save $1,000's when you sign up for Joomlashack's Everything Club.
You will get your hands on our extensive range of over 20 extensions, plus legendary support!