[+FEATURE] Fluid v4 (Core): Set layoutName by variable
authorRens Admiraal <r.admiraal@drecomm.nl>
Fri, 4 Feb 2011 08:30:31 +0000 (09:30 +0100)
committerRens Admiraal <r.admiraal@drecomm.nl>
Tue, 8 Feb 2011 08:32:43 +0000 (09:32 +0100)
v4 version of https://review.typo3.org/#change,753

Change-Id: I37c08409c4f54da98610c1170ea5f712c107877a

typo3/sysext/fluid/Classes/View/AbstractTemplateView.php
typo3/sysext/fluid/Classes/ViewHelpers/LayoutViewHelper.php

index 35fe9e8..a3cbfc8 100644 (file)
@@ -320,7 +320,13 @@ abstract class Tx_Fluid_View_AbstractTemplateView implements Tx_Extbase_MVC_View
         */
        protected function getLayoutNameInTemplate(Tx_Fluid_Core_Parser_ParsedTemplateInterface $parsedTemplate) {
                if ($this->isLayoutDefinedInTemplate($parsedTemplate)) {
-                       return $parsedTemplate->getVariableContainer()->get('layoutName');
+                       $layoutNameNode = $parsedTemplate->getVariableContainer()->get('layoutName');
+
+                       $layoutName = $layoutNameNode->evaluate($this->baseRenderingContext);
+                       if (!empty($layoutName)) {
+                               return $layoutName;
+                       }
+                       throw new Tx_Fluid_View_Exception('The layoutName could not be evaluated to a string', 1296805368);
                }
                return NULL;
        }
index f131ea5..2493922 100644 (file)
@@ -52,12 +52,12 @@ class Tx_Fluid_ViewHelpers_LayoutViewHelper extends Tx_Fluid_Core_ViewHelper_Abs
         */
        static public function postParseEvent(Tx_Fluid_Core_Parser_SyntaxTree_ViewHelperNode $syntaxTreeNode, array $viewHelperArguments, Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $variableContainer) {
                if (isset($viewHelperArguments['name'])) {
-                       $layoutName = $viewHelperArguments['name']->getText();
+                       $layoutNameNode = $viewHelperArguments['name'];
                } else {
-                       $layoutName = 'default';
+                       $layoutNameNode = new Tx_Fluid_Core_Parser_SyntaxTree_TextNode('default');
                }
 
-               $variableContainer->add('layoutName', $layoutName);
+               $variableContainer->add('layoutName', $layoutNameNode);
        }
 
        /**