‪TYPO3CMS  10.4
PageLayoutResolver.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
32 {
45  public function ‪getLayoutForPage(array $page, array $rootLine): string
46  {
47  $selectedLayout = $page['backend_layout'] ?? '';
48 
49  // If it is set to "none" - don't use any
50  if ($selectedLayout === '-1') {
51  return 'none';
52  }
53 
54  if ($selectedLayout === '' || $selectedLayout === '0') {
55  // If it not set check the root-line for a layout on next level and use this
56  // Remove first element, which is the current page
57  // See also \TYPO3\CMS\Backend\View\BackendLayoutView::getSelectedCombinedIdentifier()
58  array_shift($rootLine);
59  foreach ($rootLine as $rootLinePage) {
60  $selectedLayout = (string)($rootLinePage['backend_layout_next_level'] ?? '');
61  // If layout for "next level" is set to "none" - don't use any and stop searching
62  if ($selectedLayout === '-1') {
63  $selectedLayout = 'none';
64  break;
65  }
66  if ($selectedLayout !== '' && $selectedLayout !== '0') {
67  // Stop searching if a layout for "next level" is set
68  break;
69  }
70  }
71  }
72  if ($selectedLayout === '0' || $selectedLayout === '') {
73  $selectedLayout = 'default';
74  }
75  return $selectedLayout;
76  }
77 }
‪TYPO3\CMS\Frontend\Page\PageLayoutResolver
Definition: PageLayoutResolver.php:32
‪TYPO3\CMS\Frontend\Page
Definition: LegacyClassesForIde.php:20
‪TYPO3\CMS\Frontend\Page\PageLayoutResolver\getLayoutForPage
‪string getLayoutForPage(array $page, array $rootLine)
Definition: PageLayoutResolver.php:45