Bug #101118
openMissing translated menu entries if page is loaded via content_from_pid
Added by David Hedden over 1 year ago. Updated 7 months ago.
0%
Updated by David Hedden over 1 year 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.
Updated by David Hedden over 1 year 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
Updated by Astrid Haubold about 1 year ago
- Related to Story #101565: Frontend related translation issues added
Updated by David Hedden 7 months ago · Edited
Issue was solved with #97533 for 12.4