Joomla tutorial: How Joomla modules and menu items work together

Most likely, you know that you can assign modules to specific menu items in Joomla. You can assign modules to all, none or specific menu items. This will make the module appear when clicking on the particular menu item.

That's fine, but what do you do when you don't have a menu item for the particular article?

In this tutorial, I will show you how to have modules appear even when you don't have a (visible) menu item pointing to it.

Oftentimes, you will not have a menu item pointing to a particular article. The article might be linked to through one of several methods:

  • The front page (title and read more links)
  • Section or category views
  • The Latest news module
  • Most popular module
  • Third-party modules like Global News or Filtered news
  • etc

This means that Joomla does not have specific settings regarding the modules on the article view. Accordingly, the article view will inherit the module settings of the page linking to it. This may not be desirable, as you might want to display modules on the front page that you don't want to appear elsewhere. This is but one example.

A Common problem

I've gotten quite a few emails asking me about this problem lately. Here's one of them:

You can choose when a particular module appears based on which menu option has been clicked. If the user doesn’t click a menu option but a link instead then it gets messy trying to maintain a layout of particular modules. As an example a slide show module which appears on the front page is not desirable when reading an article after clicking a link on the front page, but since you have clicks on a read more link rather than a menu then Joomla treats as the home page.

Then, a few days ago, I got this email from another user:

I have a "Latest News" module on my front page. When I click the links in the news module I would like to display specific modules on those articles, but not in (other) content, how can I do it?

The solution

These problems are related and share a simple solution.

When you click a read more link (or title link) on the front page or in another view that creates links automatically, Joomla looks for a matching menu item for the article. If it doesn't find a menu item linking to the article, it will give the page the same settings as the front page. As mentioned, the same goes for section / category views etc.

As luck would have it, you can avoid this behavior and choose which modules appear when you click a link.

You need to make sure that the pages have a matching menu item (showing the article directly). Or that they are linked to through a list or blog view. For instance, on this blog, I have every article categorized. Most articles and categories are accessible through a menu item, either directly or by means of a blog or section view. These views have modules assigned to their respective menu items.

This means that Joomla will use the settings from the menu item. Not from the auto generated read more or title link on the front page. Joomla will look for a menu item matching the article URL and show the correct modules.

Now, I hear you saying: - But how to deal with this if I don't want a blog view showing all of the articles in a category on my site?
 
The solution is again a simple one:

  1. Create a separate menu using the Menu Manager.
  2. Create list or blog views for your sections or categories
  3. Assign the modules you want to appear to the newly created menu items
  4. Don't create a menu module or show the actual menu on the site.

Joomla will now find the menu items you created in your new (hidden) menu and show the appropriate modules.

jce-advanced-linkLinking to articles

If you use the WYSIWYG editor JCE it's very easy to link to articles. The Advanced Link popup has a content and a link browser from which you can link directly to content or menu items.

About SEF URLs and this technique

You might think that it's wise to link to an article (or other item) using the SEF URLs. The URLs created by the Joomla SEF function, sh404SEF or other components are prettier and easier to understand than the default Joomla URLs. However, when you link to anything in Joomla, use the original URL. That way, if the SEF URL changes, the link will still work.

Want to learn more?

You may want to take a look at these two, related posts that I wrote:

Read 55812 times Originally published on Friday, 27 November 2009 09:49
Last modified on Wednesday, 13 May 2015 23:23
 
comments powered by Disqus