Search code examples
typo3fluidtypo3-6.1.xflux

Dynamicly change TYPO3 fluid Layout by typeNum


I am using the extension fluidpages and want to switch the layout by the typeNum. is it possible to change the f:layout by by an condition? This wont work:

<f:layout name="{f:if(condition: '{typeNum} == 666', then: 'PageAjax', else: 'Page')}"/>

Solution

  • Suggested approach:

    <f:layout name="Page/{typeNum}"/>

    Required files:

    • Resources/Private/Layouts/Page/0.html
    • Resources/Private/Layouts/Page/666.html

    Please note: this only works if the {typeNum} variable is guaranteed to exist - if it does not, you will face a "template file not found" error with an empty filename. To avoid this, you can use the VHS extension's v:var.convert ViewHelper to ensure a proper value:

    <f:layout name="Page/{typeNum -> v:var.convert(type: 'integer')}"/>