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

Bastian Waidelich bastian at typo3.org
Mon Jun 8 16:08:14 CEST 2009


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.

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..


> 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?

Bastian


magic strings anti-pattern: 
http://en.wikipedia.org/wiki/Magic_string_(programming)


More information about the TYPO3-project-typo3v4mvc mailing list