[FEATURE] Add new TS option getData->pagelayout 23/42723/7
authorBenjamin Mack <benni@typo3.org>
Tue, 18 Aug 2015 17:12:09 +0000 (19:12 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 15 Sep 2015 12:16:51 +0000 (14:16 +0200)
Add a new TypoScript getData option to fetch the backend layout
of the current page, and if empty, use backend_layout_next_level.

Releases: master
Resolves: #69602
Change-Id: I82e01b1655c683c65f378f97558489cfeca36bf9
Reviewed-on: http://review.typo3.org/42723
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Documentation/Changelog/master/Feature-69602-SimplifyHandlingOfBackendLayoutsInFrontend.rst [new file with mode: 0644]
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-69602-SimplifyHandlingOfBackendLayoutsInFrontend.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-69602-SimplifyHandlingOfBackendLayoutsInFrontend.rst
new file mode 100644 (file)
index 0000000..2aef390
--- /dev/null
@@ -0,0 +1,37 @@
+==================================================================
+Feature: #69602 - Simplify handling of backend layouts in frontend
+==================================================================
+
+Description
+===========
+
+To avoid complex TypoScript for integrators, the handling of backend layouts is simplified for the frontend.
+
+ To get the correct backend layout, the following TypoScript code can be used:
+
+.. code-block:: typoscript
+
+       page.10 = FLUIDTEMPLATE
+       page.10 {
+         file.stdWrap.cObject = CASE
+         file.stdWrap.cObject {
+               key.data = pagelayout
+
+               default = TEXT
+               default.value = fileadmin/template/home.html
+
+               3 = TEXT
+               3.value = fileadmin/template/1-col.html
+
+               4 = TEXT
+               4.value = fileadmin/template/2-col.html
+         }
+       }
+
+Using  ``data = pagelayout`` is the same as using as
+
+.. code-block:: typoscript
+
+       field = backend_layout
+       ifEmpty.data = levelfield:-2,backend_layout_next_level,slide
+       ifEmpty.ifEmpty = default
\ No newline at end of file
index 90435e6..bb9f787 100755 (executable)
@@ -5686,7 +5686,7 @@ class ContentObjectRenderer {
                        }
                        $parts = explode(':', $secVal, 2);
                        $type = strtolower(trim($parts[0]));
-                       $typesWithOutParameters = array('level', 'date', 'current');
+                       $typesWithOutParameters = array('level', 'date', 'current', 'pagelayout');
                        $key = trim($parts[1]);
                        if (($key != '') || in_array($type, $typesWithOutParameters)) {
                                switch ($type) {
@@ -5758,6 +5758,36 @@ class ContentObjectRenderer {
                                        case 'page':
                                                $retVal = $tsfe->page[$key];
                                                break;
+                                       case 'pagelayout':
+                                               // 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
+                                               //   field = backend_layout
+                                               //   ifEmpty.data = levelfield:-2, backend_layout_next_level, slide
+                                               //   ifEmpty.ifEmpty = default
+                                               $retVal = $GLOBALS['TSFE']->page['backend_layout'];
+
+                                               // If it is set to "none" - don't use any
+                                               if ($retVal === '-1') {
+                                                       $retVal = 'none';
+                                               } elseif ($retVal === '' || $retVal === '0') {
+                                                       // If it not set check the root-line for a layout on next level and use this
+                                                       foreach ($tsfe->rootLine as $rootLinePage) {
+                                                               $retVal = (string) $rootLinePage['backend_layout_next_level'];
+                                                               // If layout for "next level" is set to "none" - don't use any and stop searching
+                                                               if ($retVal === '-1') {
+                                                                       $retVal = 'none';
+                                                                       break;
+                                                               } elseif ($retVal !== '' && $retVal !== '0') {
+                                                                       // Stop searching if a layout for "next level" is set
+                                                                       break;
+                                                               }
+                                                       }
+                                               }
+                                               if ($retVal === '0' || $retVal === '') {
+                                                       $retVal = 'default';
+                                               }
+                                               break;
                                        case 'current':
                                                $retVal = $this->data[$this->currentValKey];
                                                break;