mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
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:
commit
6931031bc9
@ -1574,15 +1574,15 @@ class Translatable extends DataExtension implements PermissionProvider {
|
|||||||
function MetaTags(&$tags) {
|
function MetaTags(&$tags) {
|
||||||
$template = '<link rel="alternate" type="text/html" title="%s" hreflang="%s" href="%s" />' . "\n";
|
$template = '<link rel="alternate" type="text/html" title="%s" hreflang="%s" href="%s" />' . "\n";
|
||||||
$translations = $this->owner->getTranslations();
|
$translations = $this->owner->getTranslations();
|
||||||
if($translations) {
|
if($translations->count()) {
|
||||||
$translations = $translations->toArray();
|
$translations = $translations->toArray();
|
||||||
$translations[] = $this->owner;
|
$translations[] = $this->owner;
|
||||||
|
|
||||||
foreach($translations as $translation) {
|
foreach($translations as $translation) {
|
||||||
$tags .= sprintf($template,
|
$tags .= sprintf($template,
|
||||||
Convert::raw2xml($translation->Title),
|
Convert::raw2xml($translation->Title),
|
||||||
i18n::convert_rfc1766($translation->Locale),
|
i18n::convert_rfc1766($translation->Locale),
|
||||||
$translation->AbsoluteLink()
|
$translation->AbsoluteLink()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user