Use the method FieldsHelper::getFields() to access the custom fields.
Code:
// add this use statement after use statements in the beginning:// use Joomla\Component\Fields\Administrator\Helper\FieldsHelper;$customFields = FieldsHelper::getFields('com_content.article', $this->item, true);$values = array_column($customFields, 'value', 'name');if ($values['canonical-url'] !== '') {$canonicalLink = '<link rel="canonical" href="' . $values['canonical-url'] . '" />';$document = Factory::getDocument();$document->addCustomTag($canonicalLink);}
Statistics: Posted by toivo — Mon Apr 08, 2024 11:42 pm