Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.



Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.


Dynamically remove menu items

Dynamically remove menu items

I am often asked how to remove menu items as the result of MetaMod rules.

The bad news: Joomla doesn't make it easy to do this. There's no way to do this from inside a module, since by the time the modules are rendered, the menus have already been calculated and possibly already rendered.

The good news: there are a couple of techniques that can help.

1. MetaTemplate (and MetaTemplate Pro) can disable individual menu items from any menu, as the result of a "rule". So you could make a rule that disables a "log in" menu item, for any logged-in users. MetaTemplate (free) uses almost exactly the same PHP rules as MetaMod, so it's not hard to pick up if you already know MetaMod. MetaTemplate Pro (commercial) has a nice GUI that lets you select things from form controls.

In this way MetaTemplate (+Pro) can directly manipulate menus in a way that MetaMod by itself can't do.

You could for example create a login and a logout entry on the same menu, then use MetaTemplate (+Pro) to disable one or the other depending on if someone is logged in or not.

2.  If you are currently using the standard Joomla mod_mainmenu module for displaying your menus, then there's a drop-in replacement on this site that can help. It's called ElastiMenu, and has all the same controls as mod_mainmenu, plus a few more.

What ElastiMenu does is that it allows you to specify which menu items in the menu are to be excluded when the menu is displayed. So you can have 2 ElastiMenus each pointing to the same base "menu", but both choosing different menu items to exclude.

For the login/logout example, you would put both a login and a logout menu item on the same menu, then make 2 ElastiMenu modules that point to that same base menu. On one you would exclude the login item, and on the other you would exclude the logout item. Finally, you would use MetaMod to choose which of the two ElastiMenu modules would actually be displayed, based on whether the user is logged in or not.

Hope that helps,

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

3330 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
Total Topics:
Total Polls:
Total Posts:
Total Posts Today:
User Info:
Total Users:
Newest User:
Members Online:
Guests Online:

There are no members online

Forum Legend:

 New Sticky