Joomla 1.5 Module Overrides

Posted by on May 20, 2009 in Joomla, Web Development | No Comments

Out of the box, Joomla 1.5 is a powerhouse of functionality. But as with any stock system, there are a few things that may need to be tweeked in order to get the result you want or expect. Take Joomla menu controls for instance. They’re fine and functional, and 90% of the time no additional work is necessary. But a common practice with menus is to output them as unordered lists (ul) and then style them with CSS instructions. So, say you want to have your menu display on a horizontal line, with pipe separators between each menu item. Easy enough to define a style for this by specifying a right- or left-side border for list items in the menu. But since that rule would apply to all the list items (including first and last), you’ll have an extra pipe (at the end or the beginning). With manually constructed menus you can simply add a special class to the last (or first) list item that will style it differently (to remove the unwanted pipe). But with Joomla menus, each list item is the same, so there’s no ability to tag one with a special class. What to do?

That’s where Joomla 1.5’s new drop-dead simple module override functionality comes into play. Jisse Reitsma explains it very well over at his tutorial on Joomla module overrides at Open Source Network. In his tutorial, he explains how to alter the menu module to automatically tag the first and last list item with “first” and “last” classes. The short version is that Joomla 1.5 allows you to define a module override by simply making a folder named the same as the module you are modifying, copying the output template of the module into this new folder, and adjusting as necessary. So in essence, you’re copying a part of the module into a new location (see tutorial for specifics), modifying it, and Joomla automatically uses your modified version instead of the stock version. This prevents your mod from getting overwritten by Joomla upgrades. Brilliant!

I’ve already got this technique working on a couple of my own installations, and plan to add this mod to every theme from now on. That is, unless the Joomla devs go ahead and just build it into into the core at some point. Hint hint. 😉

Leave a Reply

You must be logged in to post a comment.