Bug #85388
closed
Wrong page category returned in getRootLine in a localized setup
Added by Daniel Huf over 6 years ago.
Updated over 4 years ago.
Description
The returned category is taken with the uid from the pages_language_overlay instead of the default page uid.
Structure¶
Pages
- Home (uid=1)
`-- Lessons (uid=24) | overlay:Formations (uid=44)
`--- Planning (uid=13) | overlay:Planification (uid=62)
`-- Ice climbing (uid=44)
Categories
- Lesson (uid = 3) // Default German
- Formation // French
- Ice Climbing (uid = 78)// Default German
My category is assigned to "page A".
Code (not working)¶
$pageId = 13; // "Planning" but in the french view
$pageRepository = $this->getTypoScriptFrontendController()->sys_page;
$rootline = $pageRepository->getRootLine($pageId);
foreach ($rootline as $rootlinePage) {
if ($rootlinePage['categories']) {
$categoryId = explode(',', $rootlinePage['categories'])[0];
$category = $this->categoryRepository->findByUid($categoryId);
// return the category Ice Climbing (78)
var_dump($category);
}
}
Code (working but why?)¶
$pageId = 13; // "Planning" but in the french view
// Mind the difference to instantiate $pageRepository?
$pageRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Page\PageRepository::class);
$rootline = $pageRepository->getRootLine($pageId);
foreach ($rootline as $rootlinePage) {
if ($rootlinePage['categories']) {
$categoryId = explode(',', $rootlinePage['categories'])[0];
$category = $this->categoryRepository->findByUid($categoryId);
// return the category Lesson (uid=3)
var_dump($category);
}
}
- Priority changed from Must have to Should have
- Target version changed from 8.7.19 to Candidate for patchlevel
- Status changed from New to Closed
In newer versions of TYPO3 (9, 10) sys_page and the PageRepository are both using the context to set language specific settings and behave the same way. Closing this issue now. If it still occurs, feel free to comment.
Also available in: Atom
PDF