[BUGFIX] Nested FLUIDTEMPLATE doesn't work anymore 85/20585/6
authorStefan Galinski <stefan.galinski@gmail.com>
Tue, 7 May 2013 14:53:07 +0000 (16:53 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Mon, 17 Jun 2013 20:16:35 +0000 (22:16 +0200)
It's impossible since version 6.0 to render a
FLUIDTEMPLATE content object inside a
FLUIDTEMPLATE, because the internal fluid view
instance of the parent FLUIDTEMPLATE will be
overridden by the children FLUIDTEMPLATE.

Fixes: #48021
Releases: 6.2, 6.1, 6.0
Change-Id: I776a3b0a388bb47d2995041679e39ec7442459c2
Reviewed-on: https://review.typo3.org/20585
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/frontend/Classes/ContentObject/FluidTemplateContentObject.php
typo3/sysext/frontend/Tests/Unit/ContentObject/FluidTemplateContentObjectTest.php

index dd9c75c..dd6a8fa 100644 (file)
@@ -78,6 +78,7 @@ class FluidTemplateContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abstr
         * @return string The HTML output
         */
        public function render($conf = array()) {
+               $parentView = $this->view;
                $this->initializeStandaloneViewInstance();
 
                if (!is_array($conf)) {
@@ -94,8 +95,10 @@ class FluidTemplateContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abstr
                $this->assignContentObjectDataAndCurrent($conf);
 
                $content = $this->renderFluidView();
+               $content = $this->applyStandardWrapToRenderedContent($content, $conf);
 
-               return $this->applyStandardWrapToRenderedContent($content, $conf);
+               $this->view = $parentView;
+               return $content;
        }
 
        /**
index 8f0e809..b5ab977 100644 (file)
@@ -576,5 +576,40 @@ class FluidTemplateContentObjectTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                        ->with('baz', array('foo' => 'bar'));
                $this->fixture->render($configuration);
        }
+
+       /**
+        * @test
+        */
+       public function renderWorksWithNestedFluidtemplate() {
+               $this->addMockViewToFixture();
+               $configuration = array(
+                       '10' => 'FLUIDTEMPLATE',
+                       '10.' => array(
+                               'template' => 'TEXT',
+                               'template.' => array(
+                                       'value' => 'A{anotherFluidTemplate}C'
+                               ),
+                               'variables.' => array(
+                                       'anotherFluidTemplate' => 'FLUIDTEMPLATE',
+                                       'anotherFluidTemplate.' => array(
+                                               'template' => 'TEXT',
+                                               'template.' => array(
+                                                       'value' => 'B',
+                                               ),
+                                       ),
+                               ),
+                       ),
+               );
+               $expectedResult = 'ABC';
+
+               // not using mocks - actual rendering
+               $contentObjectRenderer = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
+               $fluidTemplateContentObject = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectArrayContentObject(
+                       $contentObjectRenderer
+               );
+               $result = $fluidTemplateContentObject->render($configuration);
+
+               $this->assertEquals($expectedResult, $result);
+       }
 }
 ?>
\ No newline at end of file