Bug #102268
closedTypoScript conditions for tree.pagelayout do not work correctly on page level 1
100%
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.
Updated by Stig Nørgaard Færch about 1 year 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);
Updated by Stig Nørgaard Færch about 1 year ago
Updated by Gerrit Code Review about 1 year 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
Updated by Gerrit Code Review about 1 year 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
Updated by Gerrit Code Review about 1 year 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
Updated by Nikita Hovratov 10 months ago
- Related to Bug #100764: TS condition does not work added
Updated by Nikita Hovratov 10 months ago
- Related to Bug #102890: array_reverse rootline for PageLayoutResolver::getLayoutForPage calls added
Updated by Nikita Hovratov 10 months ago
- Related to Task #100047: Modernize condition matching / expression handling added
Updated by Nikita Hovratov 10 months ago
- Related to deleted (Bug #102890: array_reverse rootline for PageLayoutResolver::getLayoutForPage calls)
Updated by Nikita Hovratov 10 months ago
- Has duplicate Bug #102890: array_reverse rootline for PageLayoutResolver::getLayoutForPage calls added
Updated by Gerrit Code Review 10 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
Updated by Gerrit Code Review 10 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
Updated by Gerrit Code Review 10 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
Updated by Gerrit Code Review 10 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
Updated by Gerrit Code Review 10 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
Updated by Gerrit Code Review 10 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
Updated by Christian Kuhn 10 months ago
- Related to Bug #98044: TypoScript conditions for tree.pagelayout do not work correctly added
Updated by Christian Kuhn 10 months ago
- Related to Feature #97816: New TypoScript parser added
Updated by Gerrit Code Review 10 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
Updated by Gerrit Code Review 10 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
Updated by Gerrit Code Review 10 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
Updated by Gerrit Code Review 10 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
Updated by Dimitri König 10 months ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset f8fd9ecd7dd041aef3d9b6fd2b290f133be93419.