---
title: "if"
manual: "TypoScript Explained"
version: "13.4"
permalink: "https://docs.typo3.org/permalink/t3tsref:if@13.4"
source: "Functions/If.rst"
rendered: "2026-09-19T07:15:48+00:00"
---

# if {#if}

Allows you to check multiple conditions.

This function returns true, if **all** of the present conditions are met
(they are connected with an "AND", a logical conjunction). If a
single condition is false, the value returned is false.

The returned value may still be negated by the [negate](https://docs.typo3.org/permalink/t3tsref:if-negate@13.4) property.

There is no else property available. The "else" branch of an "if" statement is a
missing feature. You can implement a workaround by a logic based on the
[Properties for overriding and conditions](https://docs.typo3.org/permalink/t3tsref:stdwrap-override-conditions@13.4).

Simple "if empty use different value" conditions for record data can be built
with the [TypoScript // (double slash)](https://docs.typo3.org/permalink/t3tsref:data-type-gettext-double-slash@13.4)
fallback operator.

Also check the explanations and the examples further below!

-   [Properties](https://docs.typo3.org/permalink/t3tsref:properties@13.4)
-   [Explanation](https://docs.typo3.org/permalink/t3tsref:explanation@13.4)
-   [Examples](https://docs.typo3.org/permalink/t3tsref:examples@13.4)

## Properties {#if-properties}

### bitAnd {#if-bitand}

-   **bitAnd**

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

    Returns true, if the value is part of the bit set.

    **Example**

    TYPO3 uses bits to store radio and checkboxes via TCA, `bitAnd` can be used to test against these fields.

    **EXT:site_package/Configuration/TypoScript/setup.typoscript**

    ```typoscript
    lib.hideDefaultLanguageOfPage = TEXT
    lib.hideDefaultLanguageOfPage {
      value = 0
      value {
        override = 1
        override.if {
          bitAnd.field = l18n_cfg
          value = 1
        }
      }
    }

    ```

### contains {#if-contains}

-   **contains**

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

    Returns true, if the content contains `value`.

    **Example**

    **EXT:site_package/Configuration/TypoScript/setup.typoscript**

    ```typoscript
    # Add a span tag before the page title if the page title
    # contains the string "media"
    page.10 = TEXT
    page.10 {
      data = page:title
      htmlSpecialChars = 1
      prepend = TEXT
      prepend {
        value = <span class="icon-video"></span>
        if.value.data = page:title
        if.contains = Media
      }
      outerWrap = <h1>|</h1>
    }

    ```

### directReturn {#if-directreturn}

-   **directReturn**

    -   *Type:* [boolean](https://docs.typo3.org/permalink/t3tsref:data-type-boolean@13.4)

    If this property exists, no other conditions will be checked. Instead
    the true/false of this value is returned. Can be used to set
    true/false with a TypoScript constant.

### endsWith {#if-endswith}

-   **endsWith**

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

    Returns true, if the content ends with `value`.

    **Example**

    **EXT:site_package/Configuration/TypoScript/setup.typoscript**

    ```typoscript
    # Add a footer note, if the page author ends with "Kott"
    page.100 = TEXT
    page.100 {
      value = This is an article from Benji
      htmlSpecialChars = 1
      if.value.data = page:author
      if.endsWith = Kott
      wrap = <footer>|</footer>
    }

    ```

### equals {#if-equals}

-   **equals**

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

    Returns true, if the content is equal to `value`.

    **Example**

    **EXT:site_package/Configuration/TypoScript/setup.typoscript**

    ```typoscript
    if.equals = POST
    if.value.data = GETENV:REQUEST_METHOD
    ```

### isFalse {#if-isfalse}

-   **isFalse**

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

    If the content is "false", which is empty or zero.

### isGreaterThan {#if-isgreaterthan}

-   **isGreaterThan**

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

    Returns true, if the content is greater than `value`.

### isInList {#if-isinlist}

-   **isInList**

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

    Returns true, if the content is in the comma-separated list
    `.value`.

    **Note:** The list in `value` may not have spaces between elements!

    **Example**

    **EXT:site_package/Configuration/TypoScript/setup.typoscript**

    ```typoscript
    if.isInList.field = uid
    if.value = 1,2,34,50,87
    ```

    This returns true, if the uid is part of the list in `value`.

### isLessThan {#if-islessthan}

-   **isLessThan**

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

    Returns true, if the content is less than `value`.

### isNull {#if-isnull}

-   **isNull**

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

    If the resulting content of the `stdWrap` is null (`NULL` type in PHP).

    Since null values cannot be assigned in TypoScript, only the `stdWrap`
    features are available below this property.

    **Example**

    **EXT:site_package/Configuration/TypoScript/setup.typoscript**

    ```typoscript
    page.10 = COA_INT
    page.10.10 = TEXT
    page.10.10 {
      stdWrap.if.isNull.field = description
      value = No description available.
    }

    ```

    This example returns "No description available.", if the content of
    the field "description" is `NULL`.

### isPositive {#if-ispositive}

-   **isPositive**

    -   *Type:* [integer](https://docs.typo3.org/permalink/t3tsref:data-type-integer@13.4) / [stdWrap](https://docs.typo3.org/permalink/t3tsref:stdwrap@13.4) \+ [Calc](https://docs.typo3.org/permalink/t3tsref:objects-calc@13.4)

    Returns true, if the content is positive.

### isTrue {#if-istrue}

-   **isTrue**

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

    If the content is "true", which is not empty string and not zero.

### negate {#if-negate}

-   **negate**

    -   *Type:* [boolean](https://docs.typo3.org/permalink/t3tsref:data-type-boolean@13.4)
    -   *Default:* 0

    This property is checked after all other properties. If set, it
    negates the result, which is present before its execution.

    So if all other conditions, which were used, returned true, with
    this property the overall return ends up being false. If at least
    one of the other conditions, which were used, returned false, the
    overall return ends up being true.

### startsWith {#if-startswith}

-   **startsWith**

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

    Returns true, if the content starts with `value`.

    **Example**

    **EXT:site_package/Configuration/TypoScript/setup.typoscript**

    ```typoscript
    page.10 = TEXT
    page.10 {
      value = Your editor added the magic word in the header field
      htmlSpecialChars = 1
      if.value.data = DB:tt_content:1234:header
      if.startsWith = Bazinga
    }

    ```

### value {#if-value}

-   **value**

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

    The value to check. This is the comparison value mentioned above.

## Explanation {#if-explanation}

The "if"-function is a very odd way of returning true or false!
Beware!

"if" is normally used to decide whether to render an object or to return
a value (see the [Content Objects (cObject)](https://docs.typo3.org/permalink/t3tsref:data-type-cobject@13.4) and [stdWrap](https://docs.typo3.org/permalink/t3tsref:stdwrap@13.4)).

Here is how it works:

The function returns true or false. Whether it returns true or false
depends on the properties of this function. Say if you set `isTrue = 1`
then the result is true. If you set `isTrue.field = header`, the
function returns true if the field "header" in `$cObj->data` is set!

If you want to compare values, you must load a base-value in the
`value`-property. Example:

**EXT:site_package/Configuration/TypoScript/setup.typoscript**

```typoscript
page.10.if.value = 10
page.10.if.isGreaterThan = 11
```

This would return true because the value of `isGreaterThan` is
greater than 10, which is the base-value.

More complex is this:

**EXT:site_package/Configuration/TypoScript/setup.typoscript**

```typoscript
page.10.if {
  value = 10
  isGreaterThan = 11
  isTrue.field = header
  negate = 1
}

```

There are two conditions - `isGreaterThan` and `isTrue`.
If they are both true, the total is true (both are connected with an AND).
BUT(!) then the result of the function in total would be false because the
`negate`-flag inverts the result!

## Examples {#if-examples}

This is a GIFBUILDER object that will write "NEW" on a menu-item if
the field "newUntil" has a date less than the current date!

**EXT:site_package/Configuration/TypoScript/setup.typoscript**

```typoscript
30 = TEXT
30.text = NEW!
30.offset = 10,10
30.if {
  value.data = date: U
  isLessThan.field = newUntil
  negate = 1
}

```
