The HD-Framework: Template Overrides

Learn how to use the powerful template override facility to style modules and components without editing the core code


Download for Joomla 2.5/3


wireframes | html5 | collapsible module positions | template parameters | template overrides | bootstrap


Template Overrides

When you build a custom Joomla template you have full control over the positions that your modules and components appear in. But in order to actually change the code used by a module or component you will either have to edit the core code (not advisable), or use a template override.

So if you've ever wanted your blog entries to use an H1 heading (instead of an H2) then this is for you.



The HTML folder

Joomla checks to see if you have any files in your template that are intended to "override" the core source-code equivalent. These files should all be stored in the template's "html" folder. If no files are found then the orginal files are used as per normal.


Views Template

If you inspect the file structure of your Joomla installation you'll see there is a folder for components and a folder for modules.

Each component within this folder has a "com_" prefix (com_content, com_banners, com_virtuemart, etc) whereas each module has a "mod_" prefix.
The "com_" and "mod_" folders share the similar internal structure: Within each is a "views" folder and/or a "tmpl" folder that controls the layout of a particular "template view".

For example, the "article page layout" of the standard content component is located at...
components > com_content > views > article > tmpl > default.php

and the layout of the breadcrumbs module is located at...
modules > mod_breadcrumbs > tmpl > default.php

To include these in your overrides, create a folder called "html" within your template, and then copy your desired file into this folder, using the same folder structure but removing any "components", "modules", "view" or "tmpl" folders.

Therefore the "article page layout" of the content component will become...
templates > yourtemplate > html > com_content > article > default.php

...and the "breadcrumbst" module will become...
templates > yourtemplate > html > mod_breadcrumbs > default.php


Joomla Updates

A major benefit of seperating the override from the core, is that whenever you update your Joomla version, the changes you have made are still retained (and not lost when new files are copied over them).


The drawback to this is that sometimes the files that need to be updated are the ones you have overriden.


Unfortunately there is no real solution to this, other that keeping a record of all the changes you have made and checking which files are required in each update. It's also recommended that you back up your website each time you update your Joomla version.


Web Design & Development
07845 950063