Hello guys,
We are using the joomla 3 and zoo component. We want to modify the canonical tag for zoo catagery/item.
We want to insert language code into the canonical tag.
For example: <link href="http://www.domain.com/item/iphone7-smartphone.html" rel="canonical"/>
Insert the language code: <link href="http://www.domain.com/es/iphone7-smartphone.html" rel="canonical"/>
Below is the code for zoo:
// add canonical
if ($this->app->system->document instanceof JDocumentHTML) {
$this->app->system->document->addHeadLink(JRoute::_($this->app->route->item($this->item, false), true, -1), 'canonical');
$headData = $this->app->system->document->getHeadData();
foreach ($headData['links'] as $key => $value) {
if($value['relation'] == 'canonical' && $key != JRoute::_($this->app->route->item($this->item, false), true, -1)) {
unset($headData['links'][$key]);
}
}
$this->app->system->document->setHeadData($headData);
}
Please provide the solution to me, thank you.