Project

General

Profile

Actions

Bug #91230

open

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

Added by Josef Glatz almost 4 years ago. Updated over 2 years ago.

Status:
New
Priority:
Must have
Assignee:
-
Category:
Frontend
Target version:
-
Start date:
2020-04-29
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
Tags:
menuprocessor,language,lang,mountpoint,mount,mountpointpages,translation
Complexity:
Is Regression:
Yes
Sprint Focus:

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.

Actions #1

Updated by Oliver Hader almost 4 years ago

  • Category changed from Localization to Frontend
Actions #2

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.

Actions #3

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
Actions #4

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.

Actions #5

Updated by Josef Glatz about 3 years ago

  • Description updated (diff)
  • TYPO3 Version changed from 10 to 11
Actions #6

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.

Actions

Also available in: Atom PDF