Search code examples
typo3typoscript

Can I set a typoscript lib depending on the presence of a register value?


I have the task, to display a certain breadcrumb path if a special register value is set. I tried to access these register-values directly in fluid but they seem not to be evaluatable (conditions with f.eg "greater than" dont work at all) So I came up with probably a TS-lib and I tried the blow TS. Can you see, what I want to do ? Is it possible to set "lib.defaultproductpath to 1 or 0 depending of that register value ?:

# die Anzeige des default-product path an/aus schalten
    
    lib.defaultproductpath = TEXT
    lib.defaultproductpath.value = 1
    lib.defaultproductpath.if {
         10 = TEXT
         10.data = register:level1-uid
        // isGreaterThan
    }


Solution

  • I assume:
    register:level1-uid = 0 => return 0
    register:level1-uid > 0 => return 1

    multiple option:

    lib.defaultproductpath = TEXT
    lib.defaultproductpath {
       value = 0
       override = 1
       override.if.isTrue.data = register:level1-uid
    }
    
    lib.defaultproductpath2 = TEXT
    lib.defaultproductpath2 {
       value = 1
       override = 0
       override.if.isFalse.data = register:level1-uid
    }
    
    lib.defaultproductpath3 = TEXT
    lib.defaultproductpath3 {
       value = 1
       override = 0
       override.if {
          equals = 0
          value.data = register:level1-uid
       }
    }
    
    lib.defaultproductpath4 = TEXT
    lib.defaultproductpath4 {
       value = 0
       override = 1
       override.if {
          isGreaterThan.data = register:level1-uid
          value = 0
       }
    }
    

    This result in different values if register:level1-uid < 0!