---
title: "Frontend TypoScript conditions criteria"
manual: "TypoScript Explained"
version: "main"
permalink: "https://docs.typo3.org/permalink/t3tsref:condition-functions-in-frontend-context@main"
source: "Conditions/Index.rst"
modified: "2026-09-15T19:22:01+00:00"
---

# Frontend TypoScript conditions criteria

Frontend TypoScript conditions offer a way to conditionally change TypoScript
based on current context. Do not confuse conditions with the
["if" function](https://docs.typo3.org/permalink/t3tsref:if@main), which is a [stdWrap](https://docs.typo3.org/permalink/t3tsref:stdwrap@main) property to act
on current data.

> [!NOTE]
> **See also**
>
> Have a look at the
> [TypoScript syntax condition chapter](https://docs.typo3.org/permalink/t3tsref:typoscript-syntax-conditions@main)
> for the basic syntax of conditions.

The [Symfony expression language](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/SymfonyExpressionLanguage/Index.html#symfony-expression-language)
tends to throw warnings when sub-arrays are checked in a condition that do not
exist. Use the [traverse](https://docs.typo3.org/permalink/t3tsref:condition-function-traverse@main)
function to avoid this.

-   [applicationContext](https://docs.typo3.org/permalink/t3tsref:applicationcontext@main)
-   [page](https://docs.typo3.org/permalink/t3tsref:page@main)
-   [tree](https://docs.typo3.org/permalink/t3tsref:tree@main)
-   [backend](https://docs.typo3.org/permalink/t3tsref:backend@main)
-   [frontend](https://docs.typo3.org/permalink/t3tsref:frontend@main)
-   [workspace](https://docs.typo3.org/permalink/t3tsref:workspace@main)
-   [typo3](https://docs.typo3.org/permalink/t3tsref:typo3@main)
-   [date()](https://docs.typo3.org/permalink/t3tsref:date@main)
-   [like()](https://docs.typo3.org/permalink/t3tsref:like@main)
-   [traverse()](https://docs.typo3.org/permalink/t3tsref:traverse@main)
-   [compatVersion()](https://docs.typo3.org/permalink/t3tsref:compatversion@main)
-   [getTSFE(): Migration](https://docs.typo3.org/permalink/t3tsref:gettsfe-migration@main)
-   [getenv()](https://docs.typo3.org/permalink/t3tsref:getenv@main)
-   [feature()](https://docs.typo3.org/permalink/t3tsref:feature@main)
-   [ip()](https://docs.typo3.org/permalink/t3tsref:ip@main)
-   [request()](https://docs.typo3.org/permalink/t3tsref:request@main)
-   [session()](https://docs.typo3.org/permalink/t3tsref:session@main)
-   [site()](https://docs.typo3.org/permalink/t3tsref:site@main)
-   [siteLanguage()](https://docs.typo3.org/permalink/t3tsref:sitelanguage@main)
-   [locale()](https://docs.typo3.org/permalink/t3tsref:locale@main)
-   [Examples](https://docs.typo3.org/permalink/t3tsref:examples@main)

## applicationContext

-   **applicationContext**

    -   *Type:* String

    The current application context as a string.
    See [Application context](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/RequestLifeCycle/Bootstrapping.html#bootstrapping-context).

    Example:

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

    ```typoscript
    [applicationContext == "Development"]
        # ...
    [END]

    # Any context that is "Production" or starts with "Production"
    # (for example, Production/Staging").
    [applicationContext matches "/^Production/"]
        # ...
    [END]
    ```

## page

-   **page**

    -   *Type:* Array

    All data of the current page record as array.

    Example:

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

    ```typoscript
    # Check single page UID
    [traverse(page, "uid") == 2]
        # ...
    [END]

    # Check list of page UIDs
    [traverse(page, "uid") in [17,24]]
        # ...
    [END]

    # Check list of page UIDs NOT in
    [traverse(page, "uid") not in [17,24]]
        # ...
    [END]

    # Check range of pages (example: page UID from 10 to 20)
    [traverse(page, "uid") in 10..20]
        # ...
    [END]

    # Check the page backend layout
    [traverse(page, "backend_layout") == 5]
        # ...
    [END]
    [traverse(page, "backend_layout") == "example_layout"]
        # ...
    [END]

    # Check the page title
    [traverse(page, "title") == "foo"]
        # ...
    [END]
    ```

## tree

-   **tree**

    -   *Type:* Object

    Object with tree information.

### tree.level

-   **tree.level**

    -   *Type:* Integer

    The current tree level.

    Example:

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

    ```typoscript
    # Check, if the page is on level 0:
    [tree.level == 0]
        # ...
    [END]
    ```

### tree.pagelayout

-   **tree.pagelayout**

    -   *Type:* Integer / String

    Check for the defined [backend layout](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Backend/BackendLayout.html#be-layout) of a page, including
    the inheritance of the field `Backend Layout (subpages of this page)`.

    Example:

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

    ```typoscript
    # Using backend layout records
    [tree.pagelayout === "2"]
        # ...
    [END]

    # Using the TSconfig provider of backend layouts
    [tree.pagelayout === "pagets__Home"]
        # ...
    [END]

    # Using backend layout records multiple
    [tree.pagelayout in ['2','3','4','5']]
        # ...
    [END]
    ```

    > [!WARNING]
    > **Attention**
    >
    > The value of `pagelayout` is a string, even when using BE layout records.
    > This is especially important in conditions using `in` as shown here since
    > this operator performs a strict comparison by default. For clarity and
    > consistency strict comparisons should also be used in other cases.

### tree.rootLine

-   **tree.rootLine**

    -   *Type:* Array

    Array of arrays with UID and PID.

    Example:

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

    ```typoscript
    [tree.rootLine[0]["uid"] == 1]
        # ...
    [END]
    ```

### tree.rootLineIds

-   **tree.rootLineIds**

    -   *Type:* Array

    An array with UIDs of the root line.

    Example:

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

    ```typoscript
    # Check, if page with uid 2 is inside the root line
    [2 in tree.rootLineIds]
        # ...
    [END]
    ```

### tree.rootLineParentIds

-   **tree.rootLineParentIds**

    -   *Type:* Array

    An array with parent UIDs of the root line.

    Example:

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

    ```typoscript
    # Check, if the page with UID 2 is the parent of a page inside the root line
    [2 in tree.rootLineParentIds]
        # ...
    [END]
    ```

## backend

-   **backend**

    -   *Type:* Object

    Object with backend information.

### backend.user

-   **backend.user**

    -   *Type:* Object

    Object with current backend user information.

### backend.user.isAdmin

-   **backend.user.isAdmin**

    -   *Type:* Boolean

    True, if the current backend user is administrator.

    Example:

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

    ```typoscript
    # Evaluates to true, if the current backend user is administrator
    [backend.user.isAdmin]
        # ...
    [END]
    ```

### backend.user.isLoggedIn

-   **backend.user.isLoggedIn**

    -   *Type:* Boolean

    True, if the current backend user is logged in.

    Example:

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

    ```typoscript
    # Evaluates to true, if a backend user is logged in
    [backend.user.isLoggedIn]
        # ...
    [END]
    ```

### backend.user.userId

-   **backend.user.userId**

    -   *Type:* Integer

    UID of the the current backend user.

    Example:

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

    ```typoscript
    # Evaluates to true, if the user UID of the current logged-in backend
    # user is equal to 5
    [backend.user.userId == 5]
        # ...
    [END]
    ```

### backend.user.userGroupIds

-   **backend.user.userGroupIds**

    -   *Type:* Array
    -   *Context:* Frontend, backend

    Array of user group IDs assigned to the current backend user.

    Example:

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

    ```typoscript
    [2 in backend.user.userGroupIds]
        # ...
    [END]
    ```

### backend.user.userGroupList

-   **backend.user.userGroupList**

    -   *Type:* String

    Comma-separated list of group UIDs.

    Example:

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

    ```typoscript
    [like(","~backend.user.userGroupList~",", "*,1,*")]
        # ...
    [END]
    ```

## frontend

-   **frontend**

    -   *Type:* Object

    Object with frontend information.

### frontend.user

-   **frontend.user**

    -   *Type:* Object

    Object with current frontend user information.

### frontend.user.isLoggedIn

-   **frontend.user.isLoggedIn**

    -   *Type:* Boolean

    True, if the current frontend user is logged in.

    Example:

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

    ```typoscript
    [frontend.user.isLoggedIn]
        # ...
    [END]
    ```

### frontend.user.userId

-   **frontend.user.userId**

    -   *Type:* Integer

    The UID of the current frontend user.

    Example:

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

    ```typoscript
    [frontend.user.userId == 5]
        # ...
    [END]
    ```

### frontend.user.userGroupIds

-   **frontend.user.userGroupIds**

    -   *Type:* Array
    -   *Context:* Frontend

    Array of user group IDs of the current frontend user.

    Example:

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

    ```typoscript
    [4 in frontend.user.userGroupIds]
        # ...
    [END]
    ```

### frontend.user.userGroupList

-   **frontend.user.userGroupList**

    -   *Type:* String

    Comma-separated list of group UIDs.

    Example:

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

    ```typoscript
    [like(","~frontend.user.userGroupList~",", "*,1,*")]
        # ...
    [END]
    ```

## workspace

-   **workspace**

    -   *Type:* Object

    Object with [workspace](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Workspaces/Index.html#workspaces) information.

### workspace.workspaceId

-   **workspace.workspaceId**

    -   *Type:* Integer

    UID of the current workspace.

    Example:

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

    ```typoscript
    # Check, if in live workspace
    [workspace.workspaceId == 0]
        # ...
    [END]
    ```

### workspace.isLive

-   **workspace.isLive**

    -   *Type:* Boolean

    True, if the current workspace is the live workspace.

    Example:

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

    ```typoscript
    [workspace.isLive]
        # ...
    [END]
    ```

### workspace.isOffline

-   **workspace.isOffline**

    -   *Type:* Boolean

    True, if the current workspace is offline.

    Example:

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

    ```typoscript
    [workspace.isOffline]
        # ...
    [END]
    ```

## typo3

-   **typo3**

    -   *Type:* Object

    Object with TYPO3-related information.

### typo3.version

-   **typo3.version**

    -   *Type:* String

    TYPO3_version (for example, 14.3.1)

    Example:

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

    ```typoscript
    [typo3.version == "14.3.1"]
        # ...
    [END]
    ```

### typo3.branch

-   **typo3.branch**

    -   *Type:* String

    TYPO3 branch (for example, 14.3)

    Example:

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

    ```typoscript
    [typo3.branch == "14.3"]
        # ...
    [END]
    ```

### typo3.devIpMask

-   **typo3.devIpMask**

    -   *Type:* String

    [$GLOBALS\['TYPO3_CONF_VARS'\]\['SYS'\]\['devIPmask'\]](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/Configuration/Typo3ConfVars/SYS.html#typo3ConfVars_sys_devIPmask)

    Example:

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

    ```typoscript
    [typo3.devIpMask == "172.18.0.6"]
        # ...
    [END]
    ```

## date()

-   **date()**

    -   *Parameter:* String
    -   *type:* String | Integer

    Get the current date in the given format. See the PHP [date function](https://www.php.net/manual/en/function.date.php)
    as a reference for the possible usage.

    Example:

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

    ```typoscript
    # True, if the day of the current month is 7
    [date("j") == 7]
        # ...
    [END]

    # True, if the day of the current week is 7
    [date("w") == 7]
        # ...
    [END]

    # True, if the day of the current year is 7
    [date("z") == 7]
        # ...
    [END]

    # True, if the current hour is 7
    [date("G") == 7]
        # ...
    [END]
    ```

## like()

-   **like()**

    -   *Parameter:* String, String
    -   *type:* Boolean

    This function has two parameters: The first parameter is the string to
    search in, the second parameter is the search string.

    Example:

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

    ```typoscript
    # Search a string with * within another string
    [like("fooBarBaz", "*Bar*")]
        # ...
    [END]

    # Search string with single characters in between, using ?
    [like("fooBarBaz", "f?oBa?Baz")]
        # ...
    [END]

    # Search string using regular expression
    [like("fooBarBaz", "/f[o]{2,2}[aBrz]+/")]
        # ...
    [END]
    ```

## traverse()

-   **traverse()**

    -   *Parameter:* Array, String
    -   *type:* Mixed

    This function gets a value from an array with arbitrary depth and suppresses
    a PHP warning when sub-arrays do not exist. It has two parameters: The first
    parameter is the array to traverse, the second parameter is the path to
    traverse.

    In case the path is not found in the array, an empty string is returned.

    Example:

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

    ```typoscript
    # Traverse query parameters of current request along tx_news_pi1[news]
    [request && traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0]

    # Traverse page properties for current page
    [traverse(page ?? [], "pid") == 65]
    ```

    > [!TIP]
    > Checking for the [request object](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/RequestLifeCycle/Typo3Request.html#typo3-request) to be
    > available before using `traverse()` may be necessary, for
    > example, when using [Extbase](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/Extbase/Index.html#extbase) repositories in
    > [CLI](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/CommandControllers/Index.html#symfony-console-commands) context (as Extbase
    > depends on TypoScript and on the command line is no request object
    > available). This avoids the error
    > `Unable to call method "getQueryParams" of non-object "request"`.
    >
    > Same is true for the `page` variable, which might not be available
    > in all contexts, for example backend modules without a page.
    > One can use the `?? []` workaround.

## compatVersion()

-   **compatVersion()**

    -   *Parameter:* String
    -   *type:* Boolean

    Compares against the current TYPO3 branch.

    Example:

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

    ```typoscript
    # True, if the current TYPO3 version is 14.3.x
    [compatVersion("14.3")]
        # ...
    [END]

    # True, if the current TYPO3 version is 14.3.1
    [compatVersion("14.3.1")]
        # ...
    [END]
    ```

## getTSFE(): Migration

> [!NOTE]
> **Changed in version 14.0**
>
> [Breaking: #107473 - TypoScript condition function getTSFE() removed](https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/14.0/Breaking-107473-TypoScriptConditionFunctionGetTSFERemoved.html#breaking-107473-1758113238)
> The TypoScript condition function `getTSFE()` has been removed. Using a
> condition like `getTSFE()` will never evaluate to true and needs adaption.

**EXT:site_package/Configuration/Sets/Main/setup.typoscript (diff)**

```diff
- [getTSFE() && getTSFE().id == 42]

+ [request?.getPageArguments()?.getPageId() == 42]
```

## getenv()

-   **getenv()**

    -   *Type:* String

    PHP function [getenv](https://www.php.net/manual/en/function.getenv.php).

    Example:

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

    ```typoscript
    [getenv("VIRTUAL_HOST") == "www.example.org"]
        # ...
    [END]
    ```

## feature()

-   **feature()**

    -   *Type:* String

    Provides access to the current state of
    [feature toggles](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/Configuration/Typo3ConfVars/SYS.html#typo3ConfVars_sys_features).

    Example:

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

    ```typoscript
    # True, if the feature toggle for enforcing the Content Security Policy
    # in the frontend is enabled
    [feature("security.frontend.enforceContentSecurityPolicy") === true]
        # ...
    [END]
    ```

## ip()

-   **ip()**

    -   *Parameter:* String
    -   *type:* Boolean

    Value or constraint, wildcard or regular expression possible; special value:
    "devIP" (matches the [devIPmask](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/Configuration/Typo3ConfVars/SYS.html#typo3ConfVars_sys_devIPmask)).

    This function is only available in TypoScript frontend context.

    Example:

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

    ```typoscript
    [ip("172.18.*")]
        page.10.value = Your IP matches "172.18.*"
    [END]

    [ip("devIP")]
        page.10.value = Your IP matches the configured devIp
    [END]
    ```

## request()

-   **request()**

    -   *Type:* Mixed

    Allows to fetch information from current request.

    > [!NOTE]
    > This function cannot be used in **page TSconfig** or
    >
    > **user TSconfig** conditions. They always evaluate to false.

> [!TIP]
> Checking for the [request object](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/RequestLifeCycle/Typo3Request.html#typo3-request) before
> using in a condition may be necessary, for example, when using
> [Extbase](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/Extbase/Index.html#extbase) repositories in
> [CLI](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/CommandControllers/Index.html#symfony-console-commands) context (as Extbase
> depends on TypoScript and on the command line is no request object
> available). This avoids, for example, the error
> `Unable to call method "getQueryParams" of non-object "request"`.

### request.getQueryParams()

-   **request.getQueryParams()**

    -   *Type:* Array

    Allows to access GET parameters from current request.

    Assuming the following query within URL:

    `route=%2Fajax%2Fsystem-information%2Frender&token=5c53e9b715362e7b0c3275848068133b89bbed77&skipSessionUpdate=1`

    then the following array would be provided:

    -   **Key: `route`**

        Value: `/ajax/system-information/render`

    -   **Key: `token`**

        Value: `5c53e9b715362e7b0c3275848068133b89bbed77`

    -   **Key: `skipSessionUpdate`**

        Value: `1`

    Example:

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

    ```typoscript
    # Safely check the query parameter array to avoid error logs in case key
    # is not defined. This will check if the GET parameter
    # tx_news_pi1[news] in the URL is greater than 0:
    [request && traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0]
        # ...
    [END]
    ```

### request.getParsedBody()

-   **request.getParsedBody()**

    -   *Type:* Array

    Provide all values contained in the request body, for example, in case of
    submitted form via POST, the submitted values.

    Example:

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

    ```typoscript
    [request && traverse(request.getParsedBody(), 'foo') == 1]
        # ...
    [END]
    ```

### request.getHeaders()

-   **request.getHeaders()**

    -   *Type:* Array

    Provide all values from request headers.

    Example:

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

    ```typoscript
    [request && request.getHeaders()['Accept'] == 'json']
        page.10.value = Accepts json
    [END]

    [request && request.getHeaders()['host'][0] == 'www.example.org']
        page.20.value = The host is www.example.org
    [END]
    ```

### request.getCookieParams()

-   **request.getCookieParams()**

    -   *Type:* Array

    Provides available cookies.

    Example:

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

    ```typoscript
    [request && request.getCookieParams()['foo'] == 1]
        # ...
    [END]
    ```

### request.getNormalizedParams()

-   **request.getNormalizedParams()**

    -   *Type:* Array

    Provides access to the `\TYPO3\CMS\Core\Http\NormalizedParams` object.
    Have a look at the
    [normalized parameters of the request object](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/RequestLifeCycle/RequestAttributes/NormalizedParams.html#typo3-request-attribute-normalizedParams)
    for a list of the available methods.

    Example:

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

    ```typoscript
    [request && request.getNormalizedParams().isHttps()]
        page.10.value = HTTPS is being used
    [END]

    [request && request.getNormalizedParams().getHttpHost() == "example.org"]
        page.10.value = The host is "example.org"
    [END]
    ```

### request.getPageArguments()

-   **request.getPageArguments()**

    -   *Type:* Object

    Get the current `\TYPO3\CMS\Core\Routing\PageArguments` object with
    the resolved route parts from enhancers.

    Example:

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

    ```typoscript
    [request && request.getPageArguments().get('foo_id') > 0]
        # ...
    [END]

    # True, if current page type is 98
    [request && request.getPageArguments()?.getPageType() == 98]
        # ...
    [END]
    ```

## session()

-   **session()**

    -   *Parameter:* String
    -   *type:* Mixed

    Allows to access values of the current session. Available values depend on
    values written to the session, for example, by extensions. Use
    `|` to dig deeper into the structure for stored values.

    Example:

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

    ```typoscript
    # Match, if the session has the value 1234567 in the structure :php:`$foo['bar']`:
    [session("foo|bar") == 1234567]
        # ...
    [END]
    ```

## site()

-   **site()**

    -   *Parameter:* String
    -   *type:* Mixed

    Get a value from the [site configuration](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/SiteHandling/Index.html#sitehandling), or
    null, if no site was found or the property does not exists.

    Available information:

    -   **`site("identifier")`**

        Returns the identifier of the current site as a string.

    -   **`site("base")`**

        Returns the base of the current site as a string.

    -   **`site("rootPageId")`**

        Returns the root page UID of the current site as an integer.

    -   **`site("languages")`**

        Returns an array of the available languages for the current site.
        For deeper information, see
        [siteLanguage()](https://docs.typo3.org/permalink/t3tsref:condition-functions-in-frontend-context-function-sitelanguage@main).

    -   **`site("allLanguages")`**

        Returns an array of available and unavailable languages for the current
        site. For deeper information, see
        [siteLanguage()](https://docs.typo3.org/permalink/t3tsref:condition-functions-in-frontend-context-function-sitelanguage@main).

    -   **`site("defaultLanguage")`**

        Returns the default language for the current site.
        For deeper information, see
        [siteLanguage()](https://docs.typo3.org/permalink/t3tsref:condition-functions-in-frontend-context-function-sitelanguage@main).

    -   **`site("configuration")`**

        Returns an array with the available configuration for the current site.

    Example:

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

    ```typoscript
    # Site identifier
    [site("identifier") == "my_site"]
        # ...
    [END]

    # Match site base host
    [site("base").getHost() == "www.example.org"]
        # ...
    [END]

    # Match base path
    [site("base").getPath() == "/"]
        # ...
    [END]

    # Match root page UID
    [site("rootPageId") == 1]
        # ...
    [END]

    # Match a configuration property
    [traverse(site("configuration"), "myCustomProperty") == true]
        # ...
    [END]
    ```

    Site settings can also be used in the conditions in TypoScript constants:

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

    ```typoscript
    my.constant = my global value
    [traverse(site('configuration'), 'settings/some/setting') == 'someValue']
      my.constant = another value, if condition matches
    [global]
    ```

## siteLanguage()

-   **siteLanguage()**

    -   *Parameter:* String
    -   *type:* Mixed

    Get a value from the
    [site language configuration](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/SiteHandling/AddLanguages.html#sitehandling-addingLanguages),
    or null if no site was found or property not exists.

    Available information:

    -   **`siteLanguage("languageId")`**

        Returns the language ID as an integer.

    -   **`siteLanguage("locale")`**

        Returns the current locale as `\TYPO3\CMS\Core\Localization\Locale`.
        You can call all public methods of the object, for example
        `siteLanguage("locale").getName()` returns `en-GB` or `de-DE`.

        > [!NOTE]
        > **Changed in version 14.0**
        >
        > You can use expression [locale()](https://docs.typo3.org/permalink/t3tsref:condition-functions-in-frontend-context-function-locale@main)
        > as a shortcut to get the `Locale`.

    -   **`siteLanguage("base")`**

        Returns the configured base URL as a string.

    -   **`siteLanguage("title")`**

        Returns the internal human-readable name for this language as a string.

    -   **`siteLanguage("navigationTitle")`**

        Returns the navigation title as a string.

    -   **`siteLanguage("flagIdentifier")`**

        Returns the flag identifier as a string, for example `gb`.

    -   **`siteLanguage("typo3Language")`**

        Returns the language identifier used in TYPO3
        [XLIFF](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Localization/XliffFormat.html#xliff) files as a string, for example `default`
        or the two-letter language code.

    -   **`siteLanguage("hreflang")`**

        Returns the language information for the hreflang tag as a string.

    -   **`siteLanguage("fallbackType")`**

        Returns the language fallback mode as a string, one of `fallback`,
        `strict` or `free`.

    -   **`siteLanguage("fallbackLanguageIds")`**

        Returns the list of fallback languages as a string, for example `1,0`.

    Example:

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

    ```typoscript
    [siteLanguage("fallbackType") == "strict"]
        page.10.value = This site has a strict language fallback
    [END]

    [siteLanguage("title") == "Italy"]
        page.10.value = This site has the title "Italy"
    [END]
    ```

## locale()

-   **locale()**

    > [!NOTE]
    > **New in version 14.0**

    This expression allows integrators and developers to access
    the current site locale, which is provided as a locale object of type
    `Locale`.

    All public methods of this object are available for use,  for example
    `locale().getName()` returns `en-GB` or `de-DE`.

    > [!NOTE]
    > **See also**
    >
    > -   [TYPO3 explained: Locale API](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Localization/LocalizationApi/Locale.html#Locale-api)

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

    ```typoscript
    [locale().getName() == "en-US"]
        page.20.value = Language is American English.
    [END]
    [locale().getCountryCode() == "US"]
        page.30.value = Country code is "US".
    [END]
    [locale().isRightToLeftLanguageDirection()]
        page.40.value = This locale is written from right to left
    [END]
    ```

## Examples

### Check if a constant is set to a certain value

TypoScript constants can be used in conditions with the
[Syntax](https://docs.typo3.org/permalink/t3tsref:typoscript-syntax-conditions-syntax@main) for conditions:

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

```typoscript
[{$tx_my_extension.settings.feature1Enabled} == 1]
    page.10.value = The feature 1 of my_extension is enabled.
[ELSE]
    page.10.value = The feature 1 of my_extension is not enabled.
[END]
```

> [!NOTE]
> TypoScript constants can be used in frontend TypoScript *setup* conditions,
> but not in Frontend TypoScript *constants* conditions. At the time of
> evaluation the constants are not yet available in constants conditions.
>
> It is, however, possible to use [site settings](https://docs.typo3.org/permalink/t3tsref:confval-condition-site@main)
> in constant conditions.

### Compare constant with strict types

All constants are by default string. But as constants were replaced
before expression check, numeric values will interpreted as integer if they
were not wrapped into quotes. This may lead to miss-understanding while using
strict type comparison `===` in expressions. See following examples:

Without using strict type comparison following two examples are true if
constant is set to 1:

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

```typoscript
[{$tx_my_extension.settings.feature1Enabled} == 1]
    page.10.value = The feature 1 of my_extension is enabled.
[END]
```

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

```typoscript
[{$tx_my_extension.settings.feature1Enabled} == "1"]
    page.10.value = The feature 1 of my_extension is enabled.
[END]
```

In case of using strict type comparison only the next upper example is true.
That's because the stored number of the constant was not wrapped with quotes
and was therefor interpreted as integer.

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

```typoscript
[{$tx_my_extension.settings.feature1Enabled} === 1]
    page.10.value = The feature 1 of my_extension is enabled.
[END]
```

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

```typoscript
[{$tx_my_extension.settings.feature1Enabled} === "1"]
    page.10.value = The feature 1 of my_extension is enabled.
[END]
```

### Compare constant against strings

All constants are by default string. As they are replaced with their
contained value before expression check, you have to wrap them into quotes
to prevent interpreting the values as integer or float.

Following condition is always false:

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

```typoscript
[{$tx_my_extension.settings.feature1Enabled} == "active"]
    page.10.value = The feature 1 of my_extension is enabled.
[END]
```

If you are working with strings in conditions please do it that way:

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

```typoscript
["{$tx_my_extension.settings.feature1Enabled}" == "active"]
    page.10.value = The feature 1 of my_extension is enabled.
[END]
```

Sure, strict type string comparisons are also working:

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

```typoscript
["{$tx_my_extension.settings.feature1Enabled}" === "active"]
    page.10.value = The feature 1 of my_extension is enabled.
[END]
```

### Use constants with reserved keywords

As explained, above constants were replaced with their values before they are
processed by expression language. That allows experimental structures: If
`{$foo}` is set to the reserved [page](https://docs.typo3.org/permalink/t3tsref:condition-page@main) array
and page title is `Home` following condition is true:

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

```typoscript
[traverse({$foo}, "title") == "Home"]
    page.10.value (
        Value will be shown if constant is "page" and page title is "Home"
    )
[END]
```

After the replacement of the constant the example will result into:

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

```typoscript
[traverse(page, "title") == "Home"]
    page.10.value (
        Value will be shown if constant is "page" and page title is "Home"
    )
[END]
```
