In my TYPO3 Fluid template I have a value where I would like to check if its not empty before showing it. My way now:
<f:if condition="{myvalue}">
<div class="myclass">{myvalue}</div>
</f:if>
This works when I type in the backend a value like "test" or "2", and if I dont type anything it won't show the div tag. But when I type in the backend "0", the condition is also not true. How can I fix that the integer 0 will be showed, and if its empty (in database NULL) not be showed? (its very common that the value will be 0)
Btw i tried things like:
<f:if condition="{myvalue} !=NULL">
<f:if condition="{myvalue} >= 0">
But then also the empty value's wil be show. If I do
<f:debug>{myvalue}</f:debug>
I get things like:
myvalue = NULL
myvalue = 0
myvalue = "test"
So only the first one must not been shown.
I hope someone can help me, thank you.
0
(zero) is converted tofalse
- somwhere there it's described: php.net/manual/en/language.types.boolean.php. In your case there are at least two possible solutions, but first you must say where does{myvalue}
comes from? If it's field in the model of your ext, solution is simple, if it's just field value from cObj -> it will be little bit harder, just let me know and then I'll suggest you a solution – Clue