Template overrides allow you to make small tweaks to existing modules and components instead of having to recreate the entire functionality. For example:
- You might want to use the current login system, but you need the presentation to match the rest of your template in styling or semantic layout (and CSS changes won’t do)
- You need to swap out the main menu module to have an integrated breadcrumb, but you want the rest of the system to use it without resetting all of the menus to the new module
- You want to add a better search engine component, but you want to leave the main search module in place so it feeds directly to your new search engine.
There are generally five areas where a template override is needed :
- Module chrome change: When you want to change certain display or “chrome” aspects of the module without completely replacing the view, you can use module chrome code that will inject particular aspects into the module code.
- Creating a component override: All Joomla components are organized in the Model-View-Controller (MVC) structure, so all of the presentation logic for a component is stored in the views/ folder of the component. You can therefore override any of the presentation logic of any component.
- Overriding a third-party component or module: You can override any third-party component or module that complies with the Joomla MVC structure of building extensions with the standard Joomla system. That means you can alter the display of popular components without modifying the extension’s code.
- Special page overrides: There are special pages in the Joomla system, including the 404 page and the Offline page, that you can override with a template override.
Even better, all the template overrides are installed with your template, so you can use a single extension installation to place all these items on a site. You can essentially package an entire site presentation structure within a single file! Before you actually create a template override, it is useful to have an overview of the location of overrides within a template directory structure and how Joomla determines which override replaces which interface presentation. You can also see how these overrides are included in your template descriptor file.