Project

General

Profile

Actions

Bug #101118

open

Missing translated menu entries if page is loaded via content_from_pid

Added by David Hedden 10 months ago. Updated 10 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Start date:
2023-06-19
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
7.4
Tags:
Complexity:
medium
Is Regression:
Sprint Focus:

Related issues 1 (1 open0 closed)

Related to TYPO3 Core - Story #101565: Frontend related translation issuesNew2023-08-03

Actions
Actions #1

Updated by David Hedden 10 months ago

Problem found in 10.4, but from checking the source code it should be present in newer versions aswell.

If the current shown page is loaded via content_from_pid and a fallback language. Only pages that are also the fallback language are shown in the menu.
This happens because the menu is generated with pages that can have the fallback language uid or the requested language, but the filterMenuPages function filters with a changed context so it filters out the requested language.

https://api.typo3.org/11.5/_typo_script_frontend_controller_8php_source.html#l01282

     protected function resolveTranslatedPageId()
     {
         $this->page = $this->sys_page->getPage($this->id);
         // Accessed a default language page record, nothing to resolve
         if (empty($this->page) || (int)$this->page[$GLOBALS['TCA']['pages']['ctrl']['languageField']] === 0) {
             return;
         }
         $languageId = (int)$this->page[$GLOBALS['TCA']['pages']['ctrl']['languageField']];
         $this->page = $this->sys_page->getPage($this->page[$GLOBALS['TCA']['pages']['ctrl']['transOrigPointerField']]);
         $this->context->setAspect('language', GeneralUtility::makeInstance(LanguageAspect::class, $languageId));
         $this->id = $this->page['uid'] ?? 0;
     }

https://api.typo3.org/11.5/_abstract_menu_content_object_8php_source.html#l01142

         // If the page is hide in menu, but the menu does not include them do not show the page
         if (($data['nav_hide'] ?? false) && !($this->conf['includeNotInMenu'] ?? false)) {
             return false;
         }
         // Checking if a page should be shown in the menu depending on whether a translation exists or if the default language is disabled
         if (!$this->sys_page->isPageSuitableForLanguage($data, $this->getCurrentLanguageAspect())) {
             return false;
         }
         // Checking if the link should point to the default language so links to non-accessible pages will not happen
         if ($languageId > 0 && !empty($this->conf['protectLvar'])) {
             $pageTranslationVisibility = new PageTranslationVisibility((int)($data['l18n_cfg'] ?? 0));
             if ($this->conf['protectLvar'] === 'all' || $pageTranslationVisibility->shouldHideTranslationIfNoTranslatedRecordExists()) {
                 $olRec = $this->sys_page->getPageOverlay($data['uid'], $languageId);
                 if (empty($olRec)) {
                     // If no page translation record then page can NOT be accessed in
                     // the language pointed to, therefore we protect the link by linking to the default language
                     $data['_PAGES_OVERLAY_REQUESTEDLANGUAGE'] = '0';
                 }
             }
         }
         return true;

In my case a quick fix was reinitializing the language aspect after running getPageAndRootline since this is the only function that still uses resolveTranslatedPageId.

I suspect there could be more Problems off this kind, since the language aspect is not always initialized with a factory but fetched from the context. So in this case it would be wrong and also without the defined fallback chain.

Actions #2

Updated by David Hedden 10 months ago

  • Subject changed from Missing translated menu entries if page is a mount point to Missing translated menu entries if page is loaded via content_from_pid
Actions #3

Updated by Astrid Haubold 6 months ago

  • Related to Story #101565: Frontend related translation issues added
Actions

Also available in: Atom PDF