'TYPO3: TypoScript override if condition with and

I have a TypoScript layout and need an if statement with a second inside

stdWrap.dataWrap = <div class="grid col1 lay{field:layout}">|</div>

now set the override with if header_layout is not set to 100:

stdWrap.dataWrap.override = <div class="header"><h4>{field:header}</h4><h5>{field:subheader}</h5></div><span class="hitter"></span><div class="grid col1 lay{field:layout}">|</div>
stdWrap.dataWrap.override.if{
    value = 100
    equals.field = header_layout
    negate = 1

that worked, but if no header is set, the user don't set header_layout to hidden so i want to check if the field header is not empty, but this doesn't work:

stdWrap.dataWrap.override.if{
    value = 100
    equals.field = header_layout
    negate = 1
    isTrue.cObject = TEXT
    isTrue.cObject{
        value = 1
        if.value = 
        equals.field = header
        negate = 1

If the header is set and header_layout is 100, the simple output is rendered but if the header is empty and header_layout is not 100 the override will be rendered and add empty html tags.

I think the second condition will seen as "or" and not as "and", how should this TypoScript look like?



Solution 1:[1]

According to the Explanation in the TSref, conditions are connected with an AND.

So these very simple conditions should match:

  • header_layout must be less than 100
  • header has to be "true" (=not empty)

As TypoScript:

stdWrap.dataWrap.override.if {
  value = 100
  isLessThan.field = header_layout
  isTrue.field = header
}

Solution 2:[2]

If you use multiple conditions you have to watch for global modifiers like .negate, they can't be assigned to single conditions but on the whole result of all single conditions which are combined by and.
As far as I understand your logic I think that you missed to negate your cascaded .if. You also can avoid comparison to empty if you use the appropriate condition (.isTrue or because of negation .isFalse)

Otherwise you might need to build a complex condition.

There are a lot of options:

  • use multiple combinations of .ifempty, .override, .if
  • use COA either for your values or your condition, where every simple condition is assigned to one array object:
temp.test = COA
temp.test {
   10 = TEXT
   10 {
      value = cond1
      if {
         value = 1
         equals.field = abc
      }
   }
   20 = TEXT
   20 {
      value = cond2
      if {
         value = 2
         equals.field = def
      }
   }
}

then you could use it as is or use it to build the correct condition:

AND:

10 = TEXT
10.value = my value
10.ovreride = my override
10.override.if {
   value =cond1cond2
   equals.cObject < temp.test
}

OR:

10 = TEXT
10.value = my value
10.override = my override
10.override.if.isTrue.cObject < temp.test

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 David