Login / Status
developer.Resource
Home . Documentation . Document Library
Sponsors
hosted by punkt.deTYPO3 and Open Source Magazine

8.17. 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

This is the

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 "|<BR>". 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 {
  ....
}