Commit 5afb3940 authored by Julian Wundrak's avatar Julian Wundrak Committed by Richard Haeser
Browse files

[BUGFIX] Populate href lang URI only if the link is available

If there are e.g., records that have no translation, the
HrefLangGenerator outputs the site-base URL. Expected is that the entry
for this page is suppressed.

Change-Id: I6fbd4dd00955906dff13c0e5aceea6804c52dd1b
Resolves: #88032
Releases: master, 9.5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/60350


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: default avatarJörg Bösche <typo3@joergboesche.de>
Tested-by: Richard Haeser's avatarRichard Haeser <richard@maxserv.com>
Reviewed-by: default avatarJörg Bösche <typo3@joergboesche.de>
Reviewed-by: Richard Haeser's avatarRichard Haeser <richard@maxserv.com>
parent f1171848
......@@ -73,7 +73,7 @@ class HrefLangGenerator
$languageMenu = GeneralUtility::makeInstance(LanguageMenuProcessor::class);
$languages = $languageMenu->process($this->cObj, [], [], []);
foreach ($languages['languagemenu'] as $language) {
if ($language['available'] === 1) {
if ($language['available'] === 1 && !empty($language['link'])) {
$href = $this->getAbsoluteUrl($language['link']);
$hreflangs[] =
'<link rel="alternate" hreflang="' . htmlspecialchars($language['hreflang']) . '" href="' . htmlspecialchars($href) . '"/>';
......@@ -85,7 +85,7 @@ class HrefLangGenerator
$hreflangs[] =
'<link rel="alternate" hreflang="x-default" href="' . htmlspecialchars($href) . '"/>' . LF;
$GLOBALS['TSFE']->additionalHeaderData[] = implode(LF, $hreflangs);
$this->getTypoScriptFrontendController()->additionalHeaderData[] = implode(LF, $hreflangs);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment