Fluid icon indicating copy to clipboard operation
Fluid copied to clipboard

Not possible to use wrapper-sections in Layout(s)

Open InvisibleKind opened this issue 8 years ago • 1 comments

Hi,

I wanted to utilize the feature, which makes it possible to use sections as wrappers.

Here is my Layouts/Default.html:

<f:render section="ContentWrap" contentAs="contentVariable">
	<b>hello</b>
</f:render>

Templates/Main.html

<f:section name="ContentWrap">
	<div class="my-class">
		{contentVariable}
	</div>
</f:section>

But {contentVariable} is always null. After some debugging I found the troublemaker: \TYPO3Fluid\Fluid\View\AbstractTemplateView and exactly this part:

if ($this->getCurrentRenderingType() === self::RENDERING_LAYOUT) {
    // in case we render a layout right now, we will render a section inside a TEMPLATE.
    $renderingTypeOnNextLevel = self::RENDERING_TEMPLATE;
} else {
    $renderingContext = clone $renderingContext;
    $renderingContext->setVariableProvider($renderingContext->getVariableProvider()->getScopeCopy($variables));
    $renderingTypeOnNextLevel = $this->getCurrentRenderingType();
}

So, no variables are passed in case of rendering section inside of layout. If I simply add $renderingContext->setVariableProvider($renderingContext->getVariableProvider()->getScopeCopy($variables)); in if-section, everything works as expected.

The question: is it bug or made for purpose so?

InvisibleKind avatar Apr 18 '17 15:04 InvisibleKind

#469

s2b avatar Nov 24 '23 17:11 s2b