[TYPO3-english] Condition based on Content Element Layout

Jo Hasenau info at cybercraft.de
Sun Oct 26 11:56:57 CET 2014


> as you have a COA which renders the shown information you can vary the
> elements depending on your settings in the CE.
> just insert the stdWrap.if contructs like in 6.2 to enable/disable
> single bits of information depending on the layout field

Again - don't use if for a construct dealing with different values of 
the same field, since this can be done with CASE more easily and in a 
readable way. Didn't measure performance, but I guess it should be 
faster as well, since any other option will be ignored completely 
without having to handle at least the if clause.

Just insert a CASE element on the level before the part, that should be 
changed depending on the layout.

i.e.

  itemRendering {
   wrap.cObject = CASE
   wrap.cObject {
     key.field = layout
     # any other value of the layout field
     default = COA
     default {
       10 = LOAD_REGISTER
       10 {
          myRegister.dataWrap = {field:whatever} some value
        }
     }
     # if layout 1 is selected
     1 < .default
     1.10.myRegister.dataWrap = {field:whatever} another value
     # if layout n is selected
     n < .default
     n.10.myRegister.dataWrap = {field:whatever} another value
   }
}

You can even combine fields to get the key for CASE:

key.dataWrap  = {field:backend_layout}X{field:layout}
default = TEXT
default.value = Default Text
1X1 = TEXT
1X1.value = Value for backend layout 1 and layout 1
1X2 = TEXT
1X2.value = Value for backend layout 1 and layout 2
2X1 = TEXT
2X1.value = Value for backend layout 2 and layout 1
2X2 = TEXT
2X2.value = Value for backend layout 2 and layout 2

Of course this can even be enhanced with if, but IMHO it should not be 
used to evaluate an unknown list of variable options.

HTH

Joey

-- 
Diversity:
Die Kunst zusammen unabhängig zu denken
The art of thinking independently together.
--
Facebook: https://www.facebook.com/johasenau
Twitter: http://twitter.com/bunnyfield
Xing: http://contact.cybercraft.de
TYPO3 cookbook (2nd edition): http://www.typo3experts.com


More information about the TYPO3-english mailing list