Bug #91230
openLanguage menu on mount point page does not generate a valid link
0%
Description
Problem/Description¶
Affects 10.4, 11.x
A language switcher menu based on the MenuProcessor does not generate the correct URL to the default translation of a mount point page which is localized (also the mounted page is localized).
- The problem occurs no matter if I have a language fallback or not.
pages.mount_pid_ol
is set value 1 of the mount point page- the mount point page and the mounted page are translated (= page translations exists with different slug)
Affected example:¶
- I have a mount point page with URL slug
private-pilotes/how-to-buy
which results to a URL slug in the frontend of/en/private-pilotes/how-to-buy/
(according to the language site configuration (see below)). - This mount point page is translated. The translated URL slug is
privatpiloten/kaufen
which results to a URL slug in the frontend of/de/privatpiloten/kaufen/
. - The language menu works correctly if you are on the default language of the mount point page
/en/private-pilotes/how-to-buy/
. Both the link to the default language and the german language is correct and as expected. - But if I'm on the translated mount point page
/de/privatpiloten/kaufen/
the link to the default language of the page is/en/privatpiloten/kaufen/
instead of/en/private-pilotes/how-to-buy/
Environment¶
- TYPO3 10.4.1/10.4.2-dev
- didn't tested 9.5 because we updated the instance right from TYPO3 8 LTS where this issue did not occur. Therefore I marked this issue as a regression at least for 10 LTS.
- Pagetree with Translation
- default language (english
/en/
) - second language (german
/de/
)
- default language (english
Extract from the site configuration (language part)¶
languages:
-
title: English
enabled: true
languageId: '0'
base: /en/
typo3Language: default
locale: en_CA.UTF-8
iso-639-1: en
navigationTitle: English
hreflang: en-ca
direction: ltr
flag: ca
websiteTitle: ''
-
title: Deutsch
enabled: true
base: /de/
typo3Language: de
locale: de_DE.utf8
iso-639-1: de
websiteTitle: ''
navigationTitle: ''
hreflang: de-de
direction: ''
fallbackType: fallback
fallbacks: '0'
flag: de
languageId: '1'
TypoScript¶
Using the following dataprocessor Configuration
# Language Navigation page.10.dataProcessing.450 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor page.10.dataProcessing.450 { special = language special.value = 0,1 as = LanguageNavigation if { isTrue = {$site.nav.language.enable} } }
Acceptance Criteria¶
A language menu must always link to the correct URL slug of any translation of the actual mount point page no matter which translation of that page is active.
If there are questions or missing details, please also contact me on TYPO3 slack.
Updated by Oliver Hader almost 4 years ago
- Category changed from Localization to Frontend
Updated by Josef Glatz almost 4 years ago
I didn't tested it with generating the menu with TypoScript HMENU. But so AFAIK both are using the same underlying logic.
Updated by Josef Glatz almost 4 years ago
- Subject changed from Language menu on mount point pages does not generate a valid link to Language menu on mount point page does not generate a valid link
Updated by Robert Kärner over 3 years ago
I've had the exact same problem, and solved it by XCLASSing PageRouter:
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class PageRouter extends \TYPO3\CMS\Core\Routing\PageRouter
{
protected function resolveMountPointParameterIntoPageSlug(int $pageId, string $pagePath, array $mountPointPairs, PageRepository $pageRepository): string
{
foreach ($mountPointPairs as &$mountPointPair) {
[$mountRoot, $mountedPage] = GeneralUtility::intExplode('-', $mountPointPair);
$mountedPage = $pageRepository->getPage($mountedPage);
if ($parent = $mountedPage['l10n_parent']) {
$mountPointPair = $mountRoot . '-' . $parent;
}
}
return parent::resolveMountPointParameterIntoPageSlug($pageId, $pagePath, $mountPointPairs, $pageRepository);
}
}
However, I don't know yet the side effects of my hacky solution. Use with caution!
Reason of this bug is: Parts of the slug have to be replaced if a mounting page is linked. The PageRepository is responsible for getting the correct translated slugs.
However, it needs the UIDs of the untranslated (base) page to perform the language overlay correctly.
A mount page pair now looks like this: 0000-0000 where the first number is the mount point target, the second one is the mount point source.
Now, when we're on a page with a languageID != 0, the second number is the ID of our current, translated page.
The PageRepository is unable to perform the correct language overlay and always returns the slug of the currently selected language.
My solution fetches the l10n_parent of the second mount point parameter, and passes that to the Repository.
Updated by Josef Glatz about 3 years ago
- Description updated (diff)
- TYPO3 Version changed from 10 to 11
Updated by Kerstin Finke over 2 years ago
- TYPO3 Version changed from 11 to 9
I have the same url-bug with TYPO3 9.5 without menuprocessor, using HMENU.