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

Martin Kutschker masi-no at spam-typo3.org
Tue Jun 9 22:10:46 CEST 2009


Dan Osipov schrieb:
> It still requires a reference to get it correct.
> 
> if ($evenRow) {
>     $color = "red";
> }
> 
> is something a non-programmer can understand.
> 
> plugin.test_pi1.color.if = EQUAL
> plugin.test_pi1.color.if.comparand = red
> plugin.test_pi1.color.if.value = true

In you example you are comparing the strings "red" and "true". So this
would be more true to the PHP code (inventing the TRUE operator):

plugin.test_pi1.color.if = TRUE
plugin.test_pi1.color.if.value.data = register : evenRow

But the PHP example is probably more expressed like this (incl. the code
to determine if a row is odd or even):

color = TEXT
color.value = blue
color.override = red
color.override.if = EQUAL
# calculate the modulo base 2 of the register "rowCount"
color.override.if.value.data = register : rowCount
color.override.if.value.stdWrap.wrap = | % 2
color.override.if.value.prioriCalc = 1
color.override.if.comparand = 1

Inventing another operator we can make this much shorter and more readable:

color = TEXT
color.value = blue
color.override = red
color.override.if = ODD
color.override.if.value.data = register : rowCount

Instead of "value" and "comparand" we could also use "leftValue" and
"rightValue" ("leftHandValue"/"rightHandValue") meaning left and right
of the operator.

Masi


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