Project

General

Profile

Actions

Bug #102268

closed

TypoScript conditions for tree.pagelayout do not work correctly on page level 1

Added by Stig Nørgaard Færch 6 months ago. Updated 3 months ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
TypoScript
Start date:
2023-10-27
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

The pagelayout is not resolved correctly.

To recreate, create a rootline with 4 pages like this:

<?php
$rootLine = [
    [
        'backend_layout_next_level' => 'pagets__default', // Level 0 / TypoScript root template page
    ],
    [
        'backend_layout_next_level' => 'pagets__default', // Level 1
    ],
    [
        'backend_layout_next_level' => '',  // Level 2
    ],
    [
        'backend_layout_next_level' => '',  // Level 3
    ],
];

Add the condition:

[tree.pagelayout == "pagets__default"]
    page.10 = TEXT
    page.10.value = It works!
[else]
    page.10 = TEXT
    page.10.value = It doesn't work :(
[end]

Open the level 1 page. It doesn't work.
Open the level 2 page. It works.
Open the level 3 page. It works.


Related issues 5 (0 open5 closed)

Related to TYPO3 Core - Bug #100764: TS condition does not workResolved2023-04-26

Actions
Related to TYPO3 Core - Task #100047: Modernize condition matching / expression handlingClosed2023-02-28

Actions
Related to TYPO3 Core - Bug #98044: TypoScript conditions for tree.pagelayout do not work correctlyClosed2022-07-28

Actions
Related to TYPO3 Core - Feature #97816: New TypoScript parserClosed2022-06-27

Actions
Has duplicate TYPO3 Core - Bug #102890: array_reverse rootline for PageLayoutResolver::getLayoutForPage callsClosed2024-01-22

Actions
Actions #1

Updated by Stig Nørgaard Færch 6 months ago

I found the reason. The $rootLine array can both be sorted ascending and descending depending where it comes from. In TSFE context it is sorted descending, and array_shift will then remove the current page.
But in the context of the condition matcher, the sorting is in opposite direction, and the consequence is that the value from backend_layout_next_level is not found from the root page, as it has been removed from the rootline.

I propose to insert a krsort($rootLine) before array_shift($rootLine)

    public function getLayoutForPage(array $page, array $rootLine): string
    {
        $selectedLayout = $page['backend_layout'] ?? '';

        // If it is set to "none" - don't use any
        if ($selectedLayout === '-1') {
            return 'none';
        }

        if ($selectedLayout === '' || $selectedLayout === '0') {
            // If it not set check the root-line for a layout on next level and use this
            // Remove first element, which is the current page
            // See also \TYPO3\CMS\Backend\View\BackendLayoutView::getSelectedCombinedIdentifier()
            krsort($rootLine); // <-- Add to ensure the rootline is always sorted as descending, so it's always the current page that is removed, and not the root page
            array_shift($rootLine);
Actions #3

Updated by Stig Nørgaard Færch 6 months ago

Will try to push a commit.

Actions #4

Updated by Gerrit Code Review 6 months ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81595

Actions #5

Updated by Gerrit Code Review 6 months ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81595

Actions #6

Updated by Gerrit Code Review 6 months ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/81595

Actions #7

Updated by Nikita Hovratov 3 months ago

  • Related to Bug #100764: TS condition does not work added
Actions #8

Updated by Nikita Hovratov 3 months ago

  • Related to Bug #102890: array_reverse rootline for PageLayoutResolver::getLayoutForPage calls added
Actions #9

Updated by Nikita Hovratov 3 months ago

  • Related to Task #100047: Modernize condition matching / expression handling added
Actions #10

Updated by Nikita Hovratov 3 months ago

  • Related to deleted (Bug #102890: array_reverse rootline for PageLayoutResolver::getLayoutForPage calls)
Actions #11

Updated by Nikita Hovratov 3 months ago

  • Has duplicate Bug #102890: array_reverse rootline for PageLayoutResolver::getLayoutForPage calls added
Actions #12

Updated by Gerrit Code Review 3 months ago

Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82560

Actions #13

Updated by Gerrit Code Review 3 months ago

Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82560

Actions #14

Updated by Gerrit Code Review 3 months ago

Patch set 6 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82560

Actions #15

Updated by Gerrit Code Review 3 months ago

Patch set 7 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82560

Actions #16

Updated by Gerrit Code Review 3 months ago

Patch set 8 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82560

Actions #17

Updated by Gerrit Code Review 3 months ago

Patch set 9 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82560

Actions #18

Updated by Christian Kuhn 3 months ago

  • Related to Bug #98044: TypoScript conditions for tree.pagelayout do not work correctly added
Actions #19

Updated by Christian Kuhn 3 months ago

Actions #20

Updated by Gerrit Code Review 3 months ago

Patch set 10 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82560

Actions #21

Updated by Gerrit Code Review 3 months ago

Patch set 11 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82560

Actions #22

Updated by Gerrit Code Review 3 months ago

Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82743

Actions #23

Updated by Gerrit Code Review 3 months ago

Patch set 2 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/82743

Actions #24

Updated by Dimitri König 3 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF