---
title: "CASE"
manual: "TypoScript Explained"
version: "main"
permalink: "https://docs.typo3.org/permalink/t3tsref:cobj-case@main"
source: "ContentObjects/Case/Index.rst"
rendered: "2026-09-19T06:55:14+00:00"
---

# CASE {#cobj-case}

> [!NOTE]
> -   CASE is an object type (= complex data type).
> -   It is a specific [cObject](https://docs.typo3.org/permalink/t3tsref:cobject@main) data type.

This is a very flexible object whose rendering can vary depending on a
given key. The principle is similar to that of the "switch" construct
in PHP.

The value of the "key" property determines, which of the provided
cObjects will finally be rendered.

The "key" property is expected to match one of the values found in the
"array of cObjects". Any string can be used as value in this array,
except for those that match another property. So the forbidden values
are: "if", "setCurrent", "key", and "stdWrap". "default" also cannot
be used as it has a special meaning: If the value of the "key"
property is *not* found in the array of cObjects, then the cObject
from the "default" property will be used.

## Properties {#cobj-case-properties}

### array of cObjects {#cobj-case-array-of-cobjects}

-   **array of cObjects**

    -   *Type:* [cObject](https://docs.typo3.org/permalink/t3tsref:data-type-cobject@main)

    Array of cObjects. Use this to define cObjects for the different
    values of [key](https://docs.typo3.org/permalink/t3tsref:cobj-case-key@main). If [key](https://docs.typo3.org/permalink/t3tsref:cobj-case-key@main) has a certain value,
    the according cObject will be rendered. The cObjects can have any name, but not
    the names of the other properties of the cObject CASE.

### cache {#cobj-case-cache}

-   **cache**

    -   *Type:* [cache](https://docs.typo3.org/permalink/t3tsref:cache@main)

    See [cache function description](https://docs.typo3.org/permalink/t3tsref:cache@main) for details.

### default {#cobj-case-default}

-   **default**

    -   *Type:* [cObject](https://docs.typo3.org/permalink/t3tsref:data-type-cobject@main)

    Use this to define the rendering for *those* values of [key](https://docs.typo3.org/permalink/t3tsref:cobj-case-key@main) that
    do *not* match any of the values of the [array of cObjects](https://docs.typo3.org/permalink/t3tsref:cobj-case-array-of-cobjects@main). If no
    default cObject is defined, an empty string will be returned for
    the default case.

### if {#cobj-case-if}

-   **if**

    -   *Type:* [->if](https://docs.typo3.org/permalink/t3tsref:if@main)

    If [if](https://docs.typo3.org/permalink/t3tsref:if@main) returns false, nothing is returned.

### key {#cobj-case-key}

-   **key**

    -   *Type:* [string](https://docs.typo3.org/permalink/t3tsref:data-type-string@main) / [stdWrap](https://docs.typo3.org/permalink/t3tsref:stdwrap@main)
    -   *Default:* default

    The key, which determines, which cObject will be rendered. Its
    value is expected to match the name of one of the cObjects from
    the array of cObjects; this cObject is then rendered. If no name
    of a cObject is matched, the cObject from the property [default](https://docs.typo3.org/permalink/t3tsref:cobj-case-default@main)
    is rendered.

    This property defines the source of the value that will be matched against
    the values of the [array of cObjects](https://docs.typo3.org/permalink/t3tsref:cobj-case-array-of-cobjects@main). It will generally not be a
    simple string, but use its [stdWrap](https://docs.typo3.org/permalink/t3tsref:stdwrap@main) properties to retrieve a
    dynamic value from some specific source, typically a field of the
    current record. See the [example below](https://docs.typo3.org/permalink/t3tsref:cobj-case-examples@main).

### setCurrent {#cobj-case-setcurrent}

-   **setCurrent**

    -   *Type:* [string](https://docs.typo3.org/permalink/t3tsref:data-type-string@main) / [stdWrap](https://docs.typo3.org/permalink/t3tsref:stdwrap@main)

    Sets the "current" value.

### stdWrap {#cobj-case-stdwrap}

-   **stdWrap**

    -   *Type:* [stdWrap](https://docs.typo3.org/permalink/t3tsref:stdwrap@main)

    [stdWrap](https://docs.typo3.org/permalink/t3tsref:stdwrap@main) around any object that was rendered no matter what the
    [key](https://docs.typo3.org/permalink/t3tsref:cobj-case-key@main) value is.

## Example: {#cobj-case-examples}

If in this example the field `header` turns out not to be set ("false"), an
empty string is returned. Otherwise TYPO3 chooses between two different
renderings of some content depending on whether the [key](https://docs.typo3.org/permalink/t3tsref:cobj-case-key@main) field
`layout` is "1" or not ([default](https://docs.typo3.org/permalink/t3tsref:cobj-case-default@main)).

The result is in either case wrapped with `|<br>`.

**EXT:site_package/Configuration/Sets/Main/setup.typoscript**

```typoscript
stuff = CASE
stuff.if.isTrue.field = header
# This value determines, which of the following cObjects will be rendered.
stuff.key.field = layout

# cObject for the case that field layout is "1".
stuff.1 = TEXT
stuff.1 {
  # ....
}
# cObject for all other cases.
stuff.default = TEXT
stuff.default {
  # ....
}

stuff.stdWrap.wrap = |<br>

```
