Forum Archive - General version canonical tag in joomla 3

General version canonical tag in joomla 3
May 7, 2014 3:29 am by pacowilson
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.
Re: General version canonical tag in joomla 3
May 7, 2014 5:08 am by pacowilson
By the way, it seems the pro version doesn't translate the Open Graph Tags :cry:
Re: General version canonical tag in joomla 3
May 7, 2014 8:04 am by Edvard
Hi, First you need to change the .htaccess rules to add the possibility of language detection: # gtranslate config RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)/(.*)$ /$1/$3 [R=301,L] RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)$ /$1/ [R=301,L] RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/(.*)$ /gtranslate/translate.php?lang=$1&url=$2&glang=$1 [L,QSA] RewriteRule ^([a-z]{2}|zh-CN|zh-TW)$ /gtranslate/translate.php?lang=$1&glang=$1 [L,QSA] After that you will be able to identify the selected language by $_GET['glang'] variable. The canonical link is generated by JRoute::_($this->app->route->item($this->item, false), true, -1) function call. You need to add the language code inside of it. The easiest way is to replace it with: str_replace('domain.com/', 'domain.com/' . (empty($_GET['glang']) ? '' : $_GET['glang'] . '/'), JRoute::_($this->app->route->item($this->item, false), true, -1)) BTW. The canonical translation is integrated into our Enterprise version which allows also URL translation. Open graph tags are not translated. Let me know. Thanks!

SIMILAR TOPICS

GTranslate 3.7.4, Joomla 3.9.3 - doGTranslate is not definedFeb 22, 2019 12:34 pmReplies: 1Post by: oase
joomla google translate based on user ipAug 15, 2018 10:09 amReplies: 1Post by: ameerjaiswal
Googlebot seeing desktop version of site instead of mobilelMar 16, 2018 3:06 amReplies: 5Post by: natastna2
Joomla with 2 languajes already installedFeb 18, 2018 10:23 pmReplies: 1Post by: boutradelabs
Joomla: Modules Anywhere issuesMar 13, 2017 10:32 amReplies: 7Post by: Orangensaft

Try GTranslate with a free 15 day trial