Skip to content

User Tutorials icon

Incorrect Itemid's in Mambo and What to Do About Them

This tutorial discusses the issue of incorrect Itemid's in Mambo and what to do to prevent or fix these problems.

Let's look at the common problems Mambo users report:

Problem:

  • You have a module published to the frontpage of your Mambo site and it is appearing in other content areas of your site.
  • You have a content item published to the frontpage of your site and it is inheriting the Itemid of your frontpage.

Background:
Mambo uses Itemid's in all kinds of functions right throughout the code. This is an inheritance from the very early days of Mambo and because its so deeply entrenched in the code, its one we are stuck with until we do a complete rewrite (which is what we are doing with Mambo 5.0).

Mambo content follows a structure of sections -> categories -> content item. The menu within Mambo is not simply a navigational aid - it is right at the heart of the site. Unlike static HTML pages, there are no pages within Mambo. All content is stored in the database and is retrieved as needed, once an item is called from the browser. The menu is the key in determining whether content exists.

Cause of problem:
The Itemid that is returned is dependent on how you have structured your menu. Menu items have a hierarchy, or ranking of importance as follows (from highest priority to lowest):
Content
Link - Content Item
Link - Static Content
Table - Content Section
Table - Content Category
Blog - Content Section
Blog - Content Category …..

Now, remember that Mambo uses a Section -> Category -> Content Item structure.

When you create a link in mainmenu, the section/category/content that you link to is assigned an Itemid. When a "page" (or content item) is called by the browser Mambo looks for the right content and it does this by checking for the existence of an Itemid and assigning one if it doesn't already exist.

Now, let's look at this a bit closer…
Say you have a section called "News" and a category within that section called "Newsflash". Then you use this content to display within the Newsflash module on your frontpage.

If the "News" section is not linked to the menu, Mambo cannot retrieve an Itemid for the content items within that section. When that happens, the system will use the default Itemid, which is the same Itemid that is used for the page the module or content item is displayed on.

So, what is the effect of this?
Because the default Itemid has been assigned to that module or content item (which is Itemid=1 for the frontpage) whenever the link to that content is clicked, Mambo will think its on the frontpage and will display all frontpage content.

In the case of our Newsflash example, this would result in the Newsflash module loading onto the same page as the content items that are linked from within the module.

Solution:
Get into the habit of creating a menu link to all Sections within your Mambo site. Go to Table - Content Section, and link every section.

If you don't want these links to show on your site, create a new menu, do the linking there, and leave the menu hidden. This can easily be achieved by assigning the menu to a module position that does not exist in your template.

Bookmark This:
  • bodytext
  • Technorati
  • del.icio.us
  • Facebook
  • Google
  • StumbleUpon
  • Reddit

Whether I am developing Mambo or working on tutorials I am fuelled by coffee. Caffeine keeps me going so if you like the work I am doing please click on the cup to buy me a coffee today. Just $10 covers the cost of getting my caramel macchiato ;)

If you enjoyed this article make sure you subscribe to my RSS feed!

Leave a Reply

This is a gravatar-friendly site, enter your email address to use your gravatar.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution.