Templates

Template overrides that survive the next update

Template overrides that survive the next update

Editing a core layout works right up until the next Joomla release overwrites it. Overrides put your version in a folder the updater never touches.

Every view Joomla renders can be replaced without touching a single core file. You copy the layout into your template and edit the copy. The updater replaces the original; your copy stays where it is.

Where the file goes

The rule is the same for every component. Take the core file:

components/com_content/tmpl/article/default.php

and put your version at:

templates/YOURTEMPLATE/html/com_content/article/default.php

Modules follow the same shape, with the module name instead of the component:

templates/YOURTEMPLATE/html/mod_breadcrumbs/default.php

Layouts are a separate thing

Alongside component views, Joomla has reusable layouts under layouts/joomla/. Pagination, form fields and the content info block live there. Those override into html/layouts/:

layouts/joomla/pagination/link.php
  becomes
templates/YOURTEMPLATE/html/layouts/joomla/pagination/link.php

If you have ever wondered why editing the article layout did nothing to your pagination, this is why. They are two different systems.

Your own layouts

You can add layouts that are entirely yours and call them from anywhere:

echo LayoutHelper::render(
    'mine.promo',
    ['limit' => 3],
    JPATH_THEMES . '/YOURTEMPLATE/html/layouts'
);

That loads html/layouts/mine/promo.php and passes the array in as $displayData. It is the tidiest way to add a block that needs a database query without inventing a module for it.

Do not edit Cassiopeia itself

Cassiopeia ships with Joomla, which means core updates can and do change it. If you want to build on it, make a child template: a folder in templates/ with a templateDetails.xml that names its parent.

<extension type="template" client="site">
    <name>yourtemplate</name>
    <inheritable>0</inheritable>
    <parent>cassiopeia</parent>
</extension>

Anything the child does not define falls back to the parent. Your overrides sit in the child and are never in the updater's way.

One catch worth knowing

An override is a copy, frozen at the moment you made it. If a later Joomla release fixes a bug or adds an accessibility attribute in that layout, your copy will not get it. Keep overrides small and few, and after a major upgrade compare yours against the new core file. Ten minutes of diffing beats a year of quietly missing fixes.

Stuck on something else?

Doctor Joomla is a project of Cloudfaction, a Dutch agency building and maintaining Joomla sites since 1999. The articles are made with the help of AI, so tell us if something does not match your screen. Mail info@cloudfaction.nl if you want someone to look at yours.

Rather have someone look at it

Doctor Joomla is a Cloudfaction project.

A Dutch agency that has been building and running Joomla sites since 1999. If your site needs more than an article can fix, get in touch.