[TYPO3-mvc] How to use If-ViewHelper with other than true/false

Steffen Kamper info at sk-typo3.de
Mon Jun 8 16:29:03 CEST 2009


Hi Bastian,

Bastian Waidelich schrieb:
> Steffen Kamper wrote:
> 
> Hi Steffen,
> 
>>> If you think, there is a scenario where you really need to compare 
>>> strings, please post it here so we can discuss it!
> 
>> i think the scenario Joerg posted is a realistic one:
> 
> There was no string comparison in Joergs post - or did I miss something?
> 
> <f:if condition="{product.abc} == 1">
>     <!-- all the stuff for product.abc == 1 -->
> </f:if>
> <f:if condition="{product.abc} == 2">
>     <!-- all the stuff for product.abc == 2 -->
> </f:if>
> 
> Is possible in Fluid and will be backported asap. Although it would 
> probably be cleaner to use different (sub)templates for each product type.
> 

great. Sure, subtemplates are possible, but it should also work in one 
template if you have simple scenarios. E.g. think of displaying an 
additional description if one radio is selected.

> You should not need to compare with strings in your template because 
> that would mean that you use magic strings¹ and that there is probably a 
> better way..
>
yes, i see the problem.

> 
>> So a simple value comparison should be possible, string or integer, 
>> check for equal or not equal.
> 
> I don't want to turn down your suggestion. But can you think of a 
> concrete example where you need to compare strings?
> 

yes, select having strings as option.

vg Steffen


More information about the TYPO3-project-typo3v4mvc mailing list