Bug #85388

Wrong page category returned in getRootLine in a localized setup

Added by Daniel Huf 12 months ago. Updated 9 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
-
Start date:
2018-06-26
Due date:
% Done:

0%

TYPO3 Version:
8
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

The returned category is taken with the uid from the pages_language_overlay instead of the default page uid.

History

#1 Updated by Daniel Huf 12 months ago

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);
    }
}

#2 Updated by Daniel Huf 12 months ago

  • Priority changed from Must have to Should have

#3 Updated by Susanne Moog 9 months ago

  • Target version changed from 8.7.19 to Candidate for patchlevel

Also available in: Atom PDF