Issue Bug Closed

#91230Language menu on mount point page does not generate a valid link

Josef Glatz 04/29/20, 11:34 updated 11/01/26, 12:43

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:

  1. 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)).
  2. 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/.
  3. 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.
  4. 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/)

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.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 9

  1. Josef Glatz commented <span data-processor="relativetime" data-value="2020-04-29T12:38:13+00:00" > 04/29/20, 12:38 </span>

    I didn’t tested it with generating the menu with TypoScript HMENU. But so AFAIK both are using the same underlying logic.

  2. Josef Glatz changed subject Language menu on mount point pages does not generate a valid link Language menu on mount point page does not generate a valid link <span data-processor="relativetime" data-value="2020-04-29T15:16:19+00:00" > 04/29/20, 15:16 </span>

  3. Robert Kärner commented <span data-processor="relativetime" data-value="2020-11-12T15:12:24+00:00" > 11/12/20, 15:12 </span>

    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.

  4. Kerstin Finke commented and changed TYPO3 Version 11 9 <span data-processor="relativetime" data-value="2021-07-26T09:20:58+00:00" > 07/26/21, 09:20 </span>

    I have the same url-bug with TYPO3 9.5 without menuprocessor, using HMENU.

  5. Benni Mack commented and changed status New Needs Feedback <span data-processor="relativetime" data-value="2025-03-23T18:21:46+00:00" > 03/23/25, 18:21 </span>

    Very interesting, this means, however, that the mountpoint pairs (as described by Robert) are built the wrong way – with the localized UID in place. I can’t find a piece of code where this happens. Do you have any hints here?

  6. Georg Ringer commented and changed status Needs Feedback Closed <span data-processor="relativetime" data-value="2026-11-01T12:43:34+00:00" > 11/01/26, 12:43 </span>

    this should be fixed with #91328. if this still happens on v14, please contact me or create a new issue including information to reproduce it