Hello everyone.
I am posting the solution below.
The code suggested by Toivo works with Joomla5 (which runs with PHP minimum 8.1), but to prevent the Canonical TAG from being wrong, the following change needs to be made:
change true to false in this line:
After the well-deserved thanks to Toivo, who have been very supportive, I have two points to make:
the first is that it is strange that there isn't an updated tutorial for Joomla 4 and 5 that shows the updated code to insert into the override default.php file in order to insert the canonical tag.
The second consideration is that at this point, even for those like me who are trying to completely eliminate or minimize third-party components, it becomes more convenient to install a canonical tag plugin than to continue with overriding.
In fact, even overriding has the same drawbacks as third-party plugins, namely possible incompatibility after an upgrade.
I am posting the solution below.
The code suggested by Toivo works with Joomla5 (which runs with PHP minimum 8.1), but to prevent the Canonical TAG from being wrong, the following change needs to be made:
change true to false in this line:
Code:
$customFields = FieldsHelper::getFields('com_content.article', $this->item, true);
Code:
$customFields = FieldsHelper::getFields('com_content.article', $this->item, false);
the first is that it is strange that there isn't an updated tutorial for Joomla 4 and 5 that shows the updated code to insert into the override default.php file in order to insert the canonical tag.
The second consideration is that at this point, even for those like me who are trying to completely eliminate or minimize third-party components, it becomes more convenient to install a canonical tag plugin than to continue with overriding.
In fact, even overriding has the same drawbacks as third-party plugins, namely possible incompatibility after an upgrade.
Statistics: Posted by sgiobbio — Wed Apr 10, 2024 4:17 pm