Joomla Improved Override Management
Maybe you've heard people talk about overrides. Or maybe you've seen the mysterious notification "Overrides to check" in your Joomla 4 backend. What are these overrides you hear so much about? Astrid Günther explains.
Since Joomla 4, Improved Override Management is part of Joomla.
In my opinion, this provides useful tools when used as intended. With tools I mean two plugins:
- Installer - Override
- Quick Icon - Joomla! Overrides Update Notification
Let's take a detailed look at how the Override Manager works.
How to use the Override Manager in Joomla 4?
I will look at this in detail using a template from a third-party provider and Cassiopeia.
Initial situation
The following figure shows my example installation. The right column has green icons: Everything is up to date!
The Override Manager comes into play when you are notified of an update in the administration area and run it. Either you update Joomla itself or a third party extension.
What happens during the update?
I am updating Joomla Core in this example. But the installation of a third party extension, is done in the same way. During the update, the plugin Installer - Override checks whether a template file has changed.
For example, from Joomla 4.1.4 to Joomla 4.1.5, the file components/com_content/tmpl/article/default.php
was changed via PR 37861.
If a changed core template file is found, the installation routine checks whether there is an override for it in an installed template. If this is the case, an item is saved in the database, which is later displayed in Template Manager in the Tab Updated files.
Final state
Overview
After a successful update, an overview of the affected overrides is displayed in the Joomla dashboard.
The file components/com_content/tmpl/article/default.php
was overwritten in the sample installation in the template Cassiopeia. The third-party template has no override for the default view of an article. If there was only this file, 1 override would be suggested in the Quickicon in the Dashboard. In my example installation, 105 files were changed. So many files are rarely changed in reality!
Detailed view
To have a closer look at the files, I click on the Quick Icon or open the template manager directly via the navigation on the left side. The template manager shows me a table in which I can see how many overrides are affected in which template.
When I click on my third-party template, I don't find an entry for the components/com_content/tmpl/article/default.php
file in the Updated Files tab. This is correct, because there is no override for this file in this template.
In Cassiopeia I find an entry for components/com_content/tmpl/article/default.php
file and I click on it to have a closer look at the contents of the file.
By default, the code saved in the template override is displayed after opening the detailed view. This code overrides the original code of Joomla Core. The original Joomla code is therefore not executed. Not even if it is more up-to-date and contains new functions or bug fixes. The code snippet displayed by default is the version that differs from Joomla Core and should therefore be checked.
I am interested in the differences. So I activate the diff view via the switcher Differences. In the diff view, the text that differ are marked.
The unnecessary (because it exists twice) check in the code section
if (!empty($this->item->pagination) && $this->item->pagination && !$this->item->paginationposition && !$this->item->paginationrelative) :
is replaced with
if (!empty($this->item->pagination) && !$this->item->paginationposition && !$this->item->paginationrelative) :
It is important to realise that the text marked in red is the one that has been newly added to Joomla Core. This will not be called because it will be overwritten with the text marked in green.
The checking process
I decide whether I want to apply the change to my override.
- To take over the code, I copy the text marked in red from the bottom window with the diff view and paste it into the upper editor field instead of the green mared text.
- If I have correctly placed everything, the diff view will be empty after saving.
- Finally, I click the Close button and delete the list entry in the table that shows me all the files to be checked.
If I don't want the change, the last of the previous actions is enough . I close the window ith the diff view and delete the list entry.
Voilà! That' s all.
Further aspects
Who is the Override Manager for?
In connection with the Override Manager, I often read questions in forums and I am sure, that the questioners have not created the overrides themselves. For example:
I read the message "2 Override(s) should be checked!" after updating to 4.0.5. I have not yet created any overrides in the template files. Is this an error?
or
My Joomla 4.1.4 site reports "2 Override(s) should be checked!". I don't know how to do this?
Usually, these overrides are part of third-party templates.
Ideally, the person who created an override checks them. In this case, it's the developer of the template. In my eyes, it is the template developers who are responsible in this case. If they consider it necessary after checking, an update of the template should be created and offered via the Joomla updater.
Someone who is not able to understand and adapt PHP code will not make good use of the Override Manager function. In this case, I recommend deactivating both plug-ins. My experience is, that the display makes users feel usure what to do. It is therefore important to trust the person who created the template or coded overrides for it. In the case of the standard template Cassiopeia, these are the core developers. Someone who uses Joomla trusts them.
The Code Views in the Override Manager
Sometimes it happens that the code view is confusing. This is usually because the Override differs from the original in many lines. In this case, check whether it makes sense for the differences to be displayed.
An override that is a new design is excluded from the check by creating an alternative layout. This is done by assigning a different file name.
For example, I have a view for board members that is called vorstandsmitglied in com_contact where a diff view makes no sense. All files are checked by the Override Manager that match the original in name (or only have the date as an appendage). In the case of files with alternative names, it is the developer's task to keep them up to date.
Checking changes in the template manager is not user-friendly in the current version if many lines of code are affected. In my opinion, the views can still be used as a hint. For editing, a code editor is the better choice if many lines have been changed.
Why is the check of the Override Manager useful?
Security
If a malicious function is removed during a Joomla Core Update or Third Party Extension Update, you will recognise this if you use the Override Manager. In my opinion, it is not unreasonable to correct programme code that contains a security risk. The Internet is developing rapidly and there are more and more cases where a function that was integrated as safe later turns out to be a security risk.
Bugs
Bug fixes and improvements are the daily business. Those who do not want to follow this should consider the following: A website does not stand still if one does not integrate the PR Make Google happy again about breadcrumbs into the override in his template. But if you did adapt this improvment, you fix errors in the structured data that cause Google to classify breadcrumbs as invalid.
Or you wonder about missing automatic suggestions in Finder, the standard search extension of Joomla 4. PR 36877 offers the solution if it was because you have integrated an outdated override in your own website.
New functions
In addition to the more important points above, such as error correction and security, one notices very quickly when new functions are added. In forums, people often ask why an option is not displayed on their own website, even though it is activated in the backend. It is not uncommon for this to be due an override, which does not offer this function.
Astrid wrote this article in German on her blog: ttps://blog.astrid-guenther.de/cassiopeia-overridemanager
Some articles published on the Joomla Community Magazine represent the personal opinion or experience of the Author on the specific topic and might not be aligned to the official position of the Joomla Project
By accepting you will be accessing a service provided by a third-party external to https://magazine.joomla.org/
Comments 9
Forever, I’m using a mac software for this, now I need to try this. It will probably help a lot on complex custom websites — Thanks Joomla!
Although I've been doing the checks, the notifications have been niggling me for some time.
This great article has made me realise you can actually mark them as checked on the Updated Files Tab.
The power of good documentation...
Thank you Astrid!
@Alan N Thank you for your Feedback.
Just a quick note, @astrid: You use both the terms Override and Overwrite. Methinks, the former would be the right term
(I'm about to translate this clever article into German and this has been bogging me)
Ehm, well... it's not just black and white: https://www.grammar.com/override_vs_overwrite
but then in Joomla lingo it's called override.
Let's just say in JLingo 'override' is probably the safest term to use.
Thank you very much Chris. I will correct that.
By the way, there is already a German version:
https://blog.astrid-guenther.de/cassiopeia-overridemanager
smashing, I had not seen this