getLayoutIdentifierForPage($pageRecord, $rootLine); $layout = $this->dataProviderCollection->getBackendLayout($selectedPageLayout, $pageId); if ($layout === null) { return null; } $contentAreas = $this->eventDispatcher->dispatch(new ResolveContentAreasEvent($layout))->getContentAreas(); return new PageLayout($layout->getIdentifier(), $layout->getTitle(), new ContentAreaCollection($contentAreas)); } /** * Check if the current page has a value in the DB field "backend_layout" * if empty, check the root line for "backend_layout_next_level" * Same as TypoScript: * field = backend_layout * ifEmpty.data = levelfield:-2, backend_layout_next_level, slide * ifEmpty.ifEmpty = default */ public function getLayoutIdentifierForPage(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() array_shift($rootLine); foreach ($rootLine as $rootLinePage) { $selectedLayout = (string)($rootLinePage['backend_layout_next_level'] ?? ''); // If layout for "next level" is set to "none" - don't use any and stop searching if ($selectedLayout === '-1') { $selectedLayout = 'none'; break; } if ($selectedLayout !== '' && $selectedLayout !== '0') { // Stop searching if a layout for "next level" is set break; } } } if ($selectedLayout === '0' || $selectedLayout === '') { $selectedLayout = 'default'; } return $selectedLayout; } public function getLayoutIdentifierForPageWithoutPrefix(array $page, array $rootLine): string { $selectedLayout = $this->getLayoutIdentifierForPage($page, $rootLine); if (str_contains($selectedLayout, '__')) { return explode('__', $selectedLayout, 2)[1] ?? ''; } return $selectedLayout; } }