Merge pull request #250 from chrometoasters/pulls/249-no-translations

Fix link hreflang meta tags being output when there are no translations
This commit is contained in:
Damian Mooyman 2016-08-12 13:50:01 +12:00 committed by GitHub
commit 6931031bc9

View File

@ -1574,15 +1574,15 @@ class Translatable extends DataExtension implements PermissionProvider {
function MetaTags(&$tags) {
$template = '<link rel="alternate" type="text/html" title="%s" hreflang="%s" href="%s" />' . "\n";
$translations = $this->owner->getTranslations();
if($translations) {
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()
foreach($translations as $translation) {
$tags .= sprintf($template,
Convert::raw2xml($translation->Title),
i18n::convert_rfc1766($translation->Locale),
$translation->AbsoluteLink()
);
}
}