Are you enjoying the extensions? Did you like the support? Help others decide.

Leave a review
17Jan2018
Information
Print

Beware of template overrides

Information
First published March 29, 2016
5646 hits - No rating
 

There is a great feature that comes with Joomla! : the ability to override components, modules, layouts or even plugin outputs.

While this is wonderful for adding your own code snippets into the core components or other extensions found in the Joomla! Extensions Directory, the convenience and flexibility of it slowly becomes a burden overtime.

Why? Because the overrides, once created, are pieces of code that never get updated, if not by yourself.

Let's say you have installed this great module but, for some reason, you needed to override its output.
You went to your template's 'create overrides' section, selected the module and modified the code to your liking in the file that is now sitting into your template's 'html' directory.

From now on, no matter how many times your module gets updated by its developer, your override IS NOT.
Therefore, if there are pieces of code that have been fixed or modified in the original files, those fixes are not reflected into your overrides, unless you do take the time to compare both files at EVERY single update to the module.

And the same goes with updates to Joomla!
Every time you override the core elements, you take the risk to keep code that is not relevant anymore or code that will never be fixed, although it has been fixed in the core.

So what can you do?

First, limit the amount of extensions or core elements you override. The more overrides, the more checks will have to be done down the road.

Second, keep a record of the changes you make. Make sure you comment your code in order to remember what you did and why.

Third, make sure you keep your template up-to-date. Templates usually come with template overrides already built-in, therefore keeping the template you are using current will make sure those overrides are also updated (that only goes if the template's developers are meticulously updating the template overrides they include).

Fourth, compare original and overridden files of third-party extensions every time you update any one that you have overridden in order to make sure you copy the last fixes and modifications over to the override.

And last but not least, do compare originals and overrides for Joomla core extensions at every major Joomla update (sometimes a glance at the change log may be helpful).

That seems and is a lot of work, but this is the price to pay when using template overrides.

A rule of thumb is really that you should never put off updates. Regularly updating your website will ensure your system gets the latest code and security fixes and will make the file comparison process much easier.

Sometimes, as a developer, it may just be faster to create specific plugins that will modify outputs instead of the override mechanism... But it all depends on the extent of the changes that need to take place.