Created
November 27, 2017 12:04
-
-
Save ABooooo/072c8366717f4a195dc8897e71239029 to your computer and use it in GitHub Desktop.
if then elseif else
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Since TYPO3 8LTS | |
Since version 8 TYPO3 uses the standalone version of fluid, that was heavily developed and got tons of new features like elseif: | |
<f:if condition="{var} == 'something'"> | |
<f:then>do something</f:then> | |
<f:else if="{other-var} == 'something else'">do something else</f:else> | |
<f:else>do the other thing</f:else> | |
</f:if> | |
In addition there is support for syntax like this: | |
<f:if condition="{something} || {someOtherThing}"> | |
Something or someOtherThing | |
</f:if> | |
Until and including TYPO3 7LTS | |
With Plain Fluid you can nest two if ViewHelper: | |
<f:if condition="{var} == 'something'"> | |
<f:then> | |
// do something | |
</f:then> | |
<f:else> | |
<f:if condition="{other-var} == 'something else'"> | |
<f:then> | |
// do something else | |
</f:then> | |
<f:else> | |
// do then the other thing | |
</f:else> | |
</f:if> | |
</f:else> | |
</f:if> | |
Or you could implement your own ViewHelper or use a ViewHelper Library like VHS that have a ViewHelper that does this more elegant. | |
https://stackoverflow.com/questions/29461381/fluid-if-then-elseif-else | |
https://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewHelper/If.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment