TSref/CASE

From TYPO3Wiki

Jump to: navigation, search
TypoScript Referenz - case
Translations info
An english page for every translation.
All pagenames in english.

  en       de   nl   fr   ja   zh  

TypoScript

CASE

This provides something alike a switch-construct in PHP. The property "key" is supposed to equal the name of another property in the object (Array...) which is a cObject. If the property .[key] is defined, "default" will be used.

Strings is Array... can be anything except the reserved words "key", "default", "stdWrap", "if"

Property: Data type: Description: Default:
setCurrent string /stdWrap Sets the "current"-value.
key string /stdWrap If the value of this key is defined, that object will be returned, otherwise the default-object will be returned.
key = helloWorld
helloWorld = TEXT
helloWorld.value = this item will be returned
default cObject
Array... cObject
stdWrap ->stdWrap
if ->if if "if" returns false nothing is returned

[tsref:(cObject).CASE]

Example:
This example chooses between two different renderings of some content depending on whether the
field "layout" is "1" of not ("default"). The result is in either case wrapped with "|
". If the field "header" turns out not to be set ("false") an empty string is returned anyway.
stuff = CASE
stuff.key.field = layout
stuff.if.isTrue.field = header
stuff.stdWrap.wrap = |<BR>
stuff.default = TEXT
stuff.default {
 ....
}
stuff.1 = TEXT
stuff.1 {
 ....
}
Personal tools