Search code examples
splittypo3typoscripttypo3-7.6.x

Typoscript Split Wrap only when not empty?


I have a COA where I need to get the second line from the description field using split. The problem is I only want to wrap it if the line has something on it. I tried using required = 1 but it only works if there is no line at all (e.g. I have an empty 2nd line with something on 3rd line).

11 = TEXT
11 {
  stdWrap.field = rowDescription
  stdWrap.split {
    token.char = 10
    returnKey = 1
  }
  required = 1
  wrap = <h6>|</h6>
}

Solution

  • Try to trim the white space away before checking the result with required. To do so you need to switch to listNum instead of split due to the order of functions within the stdWrap tool kit:

    10 = COA
    10 {
      stdWrap.wrap = <h6>|</h6>
      stdWrap.required=1
      10 = TEXT
      10 {
        field = rowDescription
        listNum = 1
        listNum.splitChar = 10
        trim = 1
      }
    }