Issue Bug Closed

#101118Missing translated menu entries if page is loaded via content_from_pid

David Hedden 06/19/23, 10:03 updated 11/06/26, 07:58

Description

No description.

Reviews 0

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

History 6

  1. David Hedden commented <span data-processor="relativetime" data-value="2023-06-19T10:32:31+00:00" > 06/19/23, 10:32 </span>

    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.

  2. David Hedden changed subject Missing translated menu entries if page is a mount point Missing translated menu entries if page is loaded via content_from_pid <span data-processor="relativetime" data-value="2023-06-19T13:06:37+00:00" > 06/19/23, 13:06 </span>

  3. Benni Mack commented and changed status New Closed <span data-processor="relativetime" data-value="2026-11-06T07:58:42+00:00" > 11/06/26, 07:58 </span>

    Solved with #97533 (TYPO3 v12.0): resolveTranslatedPageId() no longer exists, and content_from_pid no longer replaces the language aspect, so the menu keeps the requested language and its fallback chain. Closing, as the reporter confirmed.