[TYPO3-project-4-3] Variation for TypoScript "if"

JoH asenau info at cybercraft.de
Thu Jun 11 15:04:37 CEST 2009


>> Could be nested as well:
>>
>> if {
>>     value = 1
>>     isLessThan = 4
>>     and {
>>         isLessThan = 2
>>         or {
>>             isInList = 1,2,3
>>         }
>>     }
>>    or {
>>         equals = 2
>>         and {
>>             isGreaterThan = 1
>>         }
>>     }
>> }
>>
>> What do you think?
>
> a) Who wants to make all this comparisons to a single value? "1" in
> your example.

Hey- after all it's just an example and "1" could be any value that should
be compared to field values, GPvar values and other parameters.

> b) Using a COA-like notation (as I have suggested) makes it easier to
> add new clauses later on.

Making it more confusing to the non TypoScript-safe programmer.
If you write my example in just one line it would be readable in the
followin way:

if  value isLessThan A and (isLessThan B or isInList C,D,E) or (equals F and
isGreaterThan G)

This would be as close as possible to the common PHP syntax as well as to
the natural language being used by people trying to describe the comparison
with their own words.

Even the current syntax is close to this, but it's confusing because some
comparisons are using kind of "mirrored" values. if you change the behvaiour
of isGreaterThan, isLessThan and isInList, the confusion should be
minimized, since I can't find anything confusing about a syntax like:

if {
    value = 1
    isLessThan = 5
    isGreaterThan = 0
    isInList = 1,2,3,4
}

Even though this example would be useless (isInList would have been enough)
it can still be read in natural language, if you just try to imagine a
simple comma between the lines with the last line being added by "and"
(which in fact combines all lines with AND):

if 1 isLessThan 5, isGreaterThan 0 and isInList 1,2,3,4

If you really want to avoid confusion and simplify the current behaviour,
IMHO this is the way to go.

HTH

Joey

-- 
Wenn man keine Ahnung hat: Einfach mal Fresse halten!
(If you have no clues: simply shut your gob sometimes!)
Dieter Nuhr, German comedian
Twitter: http://twitter.com/bunnyfield
Xing: http://contact.cybercraft.de
T3 cookbook (2nd edition): http://www.4any1.de
TYPO3 Schulung: http://workshops.eqony.com




More information about the TYPO3-project-4-3 mailing list