Template Overrides (MVC)

Template overrides are a powerful aspect of Joomla. They allow you to customize the look and functionality of your site without altering core code. This helps in many ways, including not breaking your site when updates are installed or reverting changes if you make a mistake.

The Joomla MVC, which stands for Model View Controller, looks like Figure 11-16 from a bird’s-eye view.

The Joomla Model View Controller (MVC)

Figure 11-16. The Joomla Model View Controller (MVC)

Note

Not all Joomla 1.5 components follow this design pattern, but most do. Look for a folder called views in the component folder to confirm it does.

Do not be too concerned if you don’t completely understand how MVC works. To be honest, we know a few seasoned developers that don’t fully understand it, either. The important thing to know is the presentation layer (also called View) is separate from the rest of the extension. Before Joomla loads a view file for an extension, it first checks to see if a template override for a given view file exists in the html folder inside the current template folder. If it finds one, it will use that overriding file instead of the one packaged with the extension.

Note

You can only use template overrides on components and modules, not plug-ins.

Creating a template override is easiest to understand if you see an example, so let’s create a template override for the login module (mod_login). Some ...

Get Using Joomla now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.