Search code examples
typo3typo3-9.x

Conditions with Typoscript for Fluidtemplates


I want to add a fluidtemplate with the following code

[PIDupinRootline = 39] && [treeLevel = 4]
    lib.personSubMenuBack = FLUIDTEMPLATE
    lib.personSubMenuBack {
        file = EXT:sitepackage_my_domain/Resources/Private/TT_Address/Partials/PersonSubMenuBack.html
    }
[end]

In another fluidtemplate I added

<f:cObject typoscriptObjectPath="lib.personSubMenuBack" />

Now I get errors for the pages when the condition is wrong because 'lib.personSubMenuBack' isn't found . To avoid this I added this before the condition

 lib.personSubMenuBack = FLUIDTEMPLATE
    lib.personSubMenuBack {
        file = EXT:sitepackage_my_domain/Resources/Private/TT_Address/Partials/PersonSubMenuEmpty.html

    }

I wonder if there is a more elegant way to solve the problem without an additional empty fluidtemplate PersonSubMenuEmpty


Solution

  • [PIDupinRootline = 39] && [treeLevel = 4]
        lib.personSubMenuBack = FLUIDTEMPLATE
        lib.personSubMenuBack {
            file = EXT:sitepackage_my_domain/....
        }
    [else]
        lib.personSubMenuBack = TEXT
    [end]