From 7bed02e2863b3ef96870207d2f6e687f08e9fd2d Mon Sep 17 00:00:00 2001 From: Priyashantha Date: Mon, 4 Jun 2018 12:19:46 +0530 Subject: [PATCH] Update Translatable::MetaTags() There was an issue which causes `No return tags` issue in hreflang tags added in pages when the page link contains get params. This link answer https://webmasters.stackexchange.com/questions/110458/how-to-avoid-hreflang-return-errors-with-url-that-contain-parameters?answertab=votes#tab-top suggests just add a canonical tag for the original page rather than adding hreflang tags. --- code/model/Translatable.php | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/code/model/Translatable.php b/code/model/Translatable.php index cceea13..ad5b7df 100755 --- a/code/model/Translatable.php +++ b/code/model/Translatable.php @@ -1726,18 +1726,25 @@ class Translatable extends DataExtension implements PermissionProvider */ public function MetaTags(&$tags) { - $template = '' . "\n"; - $translations = $this->owner->getTranslations(); - if ($translations) { - $translations = $translations->toArray(); - $translations[] = $this->owner; - - foreach ($translations as $translation) { - $tags .= sprintf($template, - Convert::raw2xml($translation->Title), - i18n::convert_rfc1766($translation->Locale), - $translation->AbsoluteLink() - ); + if ( + ($controller = Controller::curr()) + && count($controller->getRequest()->getVars()) + ) { + $tags .= ''; + } else { + $template = '' . "\n"; + $translations = $this->owner->getTranslations(); + if($translations->count()) { + $translations = $translations->toArray(); + $translations[] = $this->owner; + + foreach($translations as $translation) { + $tags .= sprintf($template, + Convert::raw2xml($translation->Title), + i18n::convert_rfc1766($translation->Locale), + $translation->AbsoluteLink() + ); + } } } }