5 minutes reading time (1060 words)

Using Hidden Menus

Using Hidden Menus

Have you ever wanted to add a link to an article from within another article,without adding that linked article to your site's Main Menu, but but were frustrated trying to get your favorite selection of modules to be displayed with the article? The answer to managing the display of modules lies in using a Hidden Menu. (Also called an Invisible Menu.)

The Hidden Menu

Being able to manage which frontend modules display for articles that are displayed via links in other articles, or via links in the contents of a custom module, is a feature desired by many clients. The simple answer to making this work, is to create an invisible menu with a menu item that has a 'Single Article' link to the article. This is what unlocks the magic.

It is a simple technique that makes it possible to display one or more modules in their assigned positions and manage them the same as for your usual articles just by setting up a menu item within a hidden menu. It is called a hidden menu or invisible menu because it is published to a module position that is not displayed anywhere on the website. This same technique is also used for landing pages.

Why Have a Hidden, Invisible Menu?

Most administrators of Joomla! 2.5 and 3.x site install and use JCE or a similar editor. With JCE, for example, this editor offers the ability to easily add links to related content via the JCE Media Box.

When you want to insert a link into the text of an article that displays another article or to add an article link into the content of an HTML Custom Module, you can use the JCE Media Box to choose either "Article internal link" or "external link." The problem is when you click on the link to display the content in the Frontend, the modules you expect to see just disappear. The solution to making the modules appear is to add a menu item for displaying the article in a hidden menu.

How to Setup a Hidden Menu

The solution is simple to implement, just create an additional menu called "Invisible Menu" or "Hidden Menu" that is intended to never be displayed.


Then add to that hidden menu a menu item that links to the linked article, and then use that menu item to manage the visibility of article-related modules.

So, why does this work?

When you navigate through the menu system to get to an article, the server knows which menu item you clicked on and want displayed, and that menu item points to the component (com_content in the case of articles) the type of view (Single Article) the article ID and the list of modules that were selected to go with that view of that article. In short, the menu item knows all the answers for how to properly display the article.

When you select a specific article as the target of a link, what the server knows from the (non-SEF) URL is that you want to display the content of a specific component such as com_content having a specific record number, for example article ID=123. Based on that information alone, it knows to get the linked article from the database but it doesn't know anything else about its context - what type of article it is, what other content might be related to it and what modules to show with it. So, Joomla! has programming that says when the article's ID is all that is known, go search the database of menu items to see if there is one already setup to manage the display of that article ID. If one is found, use it as if the user clicked on the menu item instead of clicking a direct link to the article. But if a menu item is NOT found, the system doesn't know what more to do so that is why your modules do not appear.

But, our purpose was that we don't want the article to be an item in the Main Menu. It isn't supposed to show up anywhere in the site's navigation. By creating a menu item in the hidden menu, the search for a menu item that has the article ID is successful and so the article displays with all appropriate modules, but since the hidden menu is not in any module position that gets rendered to the website, no one will ever see it. Voila!

This technique is also used to create "Landing Pages" for SEO purposes and inbound marketing links that similarly do not show up on the site's main navigation menu. These pages are designed for displaying targeted content designed to be seen by people using links from social media, other websites or search engines.

Here's an example:

We have 3 links ( link1 , link2 ; link3 ) in the content of an article, that link to related articles that do not have a menu item associated with them in the main navigation. So we add menu items (Link1, Link2, Link3) for these articles in the "Invisible Menu" menu.


Assign modules to our three articles by editing the menu items "Link1, Link2, Link3" in the "Invisible Menu" menu and managing the visibility of modules for that menu item. By setting this up, our desired modules will be displayed along with the content no matter how the article is linked. When processing a link to an article, Joomla! looks to find if there is any menu item in any of the menus that points to it, and if it does find one it uses the settings in that menu item to control the display of modules. No menu item, no modules.


To test this idea, create three modules for your site and set them initially to only be visible on the homepage. Make them also visible for these three articles by editing the menu items in the Hidden Menu and checking the box for visibility.


Now when you click "link1" in an article in the frontend the modules appear with the article, because they are assigned to menu items " Link1, Link2, Link3" within the "Invisible Menu" menu.


This is an English language translation and further extension of the article "Le Menu Invisible" written by Badreddine Azrar that appeared in the January 2014 issue of the Joomla! Community Magazine

Facebook et votre site Joomla!


Already Registered? Login Here
No comments made yet. Be the first to submit a comment

By accepting you will be accessing a service provided by a third-party external to https://magazine.joomla.org/