Conditions

applicationContext

applicationContext

applicationContext
Type
String

The current application context as a string. See Application context.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[applicationContext == "Development"]
Copied!

Any context that is "Production" or starts with "Production" (eg Production/Staging").

EXT:site_package/Configuration/TypoScript/setup.typoscript
[applicationContext matches "/^Production/"]
Copied!

page

page

page
Type
Array

All data of the current page record as array.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
# Check single page uid
[traverse(page, "uid") == 2]

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

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

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

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

# Check the page title
[traverse(page, "title") == "foo"]
Copied!

Constant

{$foo.bar}

{$foo.bar}
Type
Constant

Any TypoScript constant is available like before. Depending on the type of the constant you have to use different conditions.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
# If constant is an integer
[{$foo.bar} == 4711]

# If constant is a string, put constant in quotes
["{$foo.bar}" == "4711"]
Copied!

tree

tree

tree
Type
Object

Object with tree information.

tree.level

tree.level

tree.level
Type
Integer

The current tree level.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[tree.level == 0]
Copied!

tree.pagelayout

New in version 11.0

tree.pagelayout

tree.pagelayout
Type
Integer / String

Check for the defined backend layout of a page, including the inheritance of the field Backend Layout (subpages of this page).

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
# Using backend_layout records
[tree.pagelayout == 2]
  page.1 = TEXT
  page.1.value = Layout 2
[END]

# Using TSconfig provider of backend layouts
[tree.pagelayout == "pagets__Home"]
  page.1 = TEXT
  page.1.value = Layout Home
[END]
Copied!

tree.rootLine

tree.rootLine

tree.rootLine
Type
Array

Array of arrays with UID and PID.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[tree.rootLine[0]["uid"] == 1]
Copied!

tree.rootLineIds

tree.rootLineIds

tree.rootLineIds
Type
Array

An array with UIDs of the root line.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[2 in tree.rootLineIds]
Copied!

tree.rootLineParentIds

New in version 10.3

tree.rootLineParentIds

tree.rootLineParentIds
Type
Array

An array with parent UIDs of the root line.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[2 in tree.rootLineParentIds]
Copied!

backend

backend

backend
Type
Object

Object with backend information.

backend.user

backend.user

backend.user
Type
Object

Object with current backend user information.

backend.user.isAdmin

backend.user.isAdmin

backend.user.isAdmin
Type
Boolean

True, if the current backend user is administrator.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[backend.user.isAdmin]
Copied!

backend.user.isLoggedIn

backend.user.isLoggedIn

backend.user.isLoggedIn
Type
Boolean

True, if the current backend user is logged in.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[backend.user.isLoggedIn]
Copied!

backend.user.userId

backend.user.userId

backend.user.userId
Type
Integer

UID of the the current backend user.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[backend.user.userId == 5]
Copied!

backend.user.userGroupIds

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/TypoScript/setup.typoscript
[2 in backend.user.userGroupIds]
Copied!

backend.user.userGroupList

New in version 11.2

Starting with TYPO3 v11.2 backend.user.userGroupIds, an array, has been added. Use this instead of like expressions to test for the user group of the current backend user.

backend.user.userGroupList

backend.user.userGroupList
Type
String

Comma-separated list of group UIDs.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[like(","~backend.user.userGroupList~",", "*,1,*")]
Copied!

frontend

frontend

frontend
Type
Object

Object with frontend information.

frontend.user

frontend.user

frontend.user
Type
Object

Object with current frontend user information.

frontend.user.isLoggedIn

frontend.user.isLoggedIn

frontend.user.isLoggedIn
Type
Boolean

True, if the current frontend user is logged in.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[frontend.user.isLoggedIn]
Copied!

frontend.user.userId

frontend.user.userId

frontend.user.userId
Type
Integer

The UID of the current frontend user.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[frontend.user.userId == 5]
Copied!

frontend.user.userGroupIds

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/TypoScript/setup.typoscript
[4 in frontend.user.userGroupIds]
Copied!

frontend.user.userGroupList

New in version 11.2

Starting with TYPO3 v11.2 frontend.user.userGroupIds, an array has been added. Use this instead of like expressions to test for the user group of the current frontend user.

frontend.user.userGroupList

frontend.user.userGroupList
Type
String

Comma-separated list of group UIDs.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[like(","~frontend.user.userGroupList~",", "*,1,*")]
Copied!

workspace

workspace

workspace
Type
Object

Object with workspace information.

workspace.workspaceId

workspace.workspaceId

workspace.workspaceId
Type
Integer

UID of the current workspace.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[workspace.workspaceId == 0]
Copied!

workspace.isLive

workspace.isLive

workspace.isLive
Type
Boolean

True, if the current workspace is the live workspace.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[workspace.isLive]
Copied!

workspace.isOffline

workspace.isOffline

workspace.isOffline
Type
Boolean

True, if the current workspace is offline.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[workspace.isOffline]
Copied!

typo3

typo3

typo3
Type
Object

Object with TYPO3-related information.

typo3.version

typo3.version

typo3.version
Type
String

TYPO3_version (for example, 11.5.33)

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[typo3.version == "11.5.33"]
Copied!

typo3.branch

typo3.branch

typo3.branch
Type
String

TYPO3 branch (for example, 11.5)

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[typo3.branch == "11.5"]
Copied!

typo3.devIpMask

typo3.devIpMask

typo3.devIpMask
Type
String

$GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[typo3.devIpMask == "172.18.0.6"]
Copied!

date()

date()

date()
Parameter

String

type

String | Integer

Get the current date in the given format. See the PHP date function as a reference for the possible usage.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
# True, if the day of the current month is 7
[date("j") == 7]

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

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

# True, if the current hour is 7
[date("G") == 7]
Copied!

like()

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/TypoScript/setup.typoscript
# Search a string with * within another string
[like("fooBarBaz", "*Bar*")]

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

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

traverse()

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/TypoScript/setup.typoscript
# Traverse query parameters of current request along tx_news_pi1[news]
[request && traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0]
Copied!

compatVersion()

compatVersion()

compatVersion()
Parameter

String

type

Boolean

Compares against the current TYPO3 branch.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
# True, if the current TYPO3 version is 12.4.x
[compatVersion("12.4")]

# True, if the current TYPO3 version is 12.4.5
[compatVersion("12.4.5")]
Copied!

getTSFE()

getTSFE()

getTSFE()
Type
Object

Provides access to TypoScriptFrontendController $GLOBALS['TSFE'] . This function can directly access methods of TypoScriptFrontendController. This class is target of a mid-term refactoring. It should be used with care since it will eventually vanish in the future.

Using the getTSFE() function, developers have to ensure that "TSFE" is available before accessing its properties. A missing "TSFE", for example, in backend context, does no longer automatically evaluate the whole condition to false. Instead, the function returns null, which can be checked using [getTSFE() && getTSFE().id == 17].

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
# True, if the current page UID is 17. Use the page variable instead
[getTSFE() && getTSFE().id == 17]
Copied!

getenv()

getenv()

getenv()
Type
String

PHP function getenv.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[getenv("VIRTUAL_HOST") == "www.example.org"]
Copied!

feature()

feature()

feature()
Type
String

Provides access to the current state of feature toggles.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
# True, if the feature toggle for enforcing the Content Security Policy
# in the frontend is enabled
[feature("security.frontend.enforceContentSecurityPolicy") === true]
Copied!

ip()

ip()

ip()
Parameter

String

type

Boolean

Value or constraint, wildcard or regular expression possible; special value: "devIP" (matches the devIPmask).

Example:

EXT:site_package/Configuration/TypoScript/setup.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]
Copied!

request

request()

request()
Type
Mixed

Allows to fetch information from current request.

request.getQueryParams()

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

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/TypoScript/setup.typoscript
[request && request.getQueryParams()['skipSessionUpdate'] == 1]
Copied!

Safely check the query parameter array to avoid error logs in case key is not defined (see traverse()). This will check if the GET parameter tx_news_pi1[news] in the URL is greater than 0:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[request && traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0]
Copied!

request.getParsedBody()

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/TypoScript/setup.typoscript
[request && traverse(request.getParsedBody(), 'foo') == 1]
Copied!

request.getHeaders()

request.getHeaders()

request.getHeaders()
Type
Array

Provide all values from request headers.

Example:

EXT:site_package/Configuration/TypoScript/setup.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]
Copied!

request.getCookieParams()

request.getCookieParams()

request.getCookieParams()
Type
Array

Provides available cookies.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[request && request.getCookieParams()['foo'] == 1]
Copied!

request.getNormalizedParams()

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 for a list of the available methods.

Example:

EXT:site_package/Configuration/TypoScript/setup.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]
Copied!

request.getPageArguments()

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/TypoScript/setup.typoscript
[request && request.getPageArguments().get('foo_id') > 0]
Copied!

Allows migration from old condition syntax using [globalVar = GP:singlepartner > 0] to [request && request.getPageArguments().get('singlepartner') > 0].

loginUser

loginUser

loginUser
Parameter

String

type

Boolean

Value or constraint, wildcard or RegExp possible

Context dependent, uses backend user within TSconfig, and frontend user within TypoScript.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[loginUser('*')]
  # matches any login user
  page.10.value = You are logged in!
[END]

[loginUser(1)]
  page.10.value = Your frontend user has the uid 1
[END]

[loginUser('1,3,5')]
  page.10.value = Your frontend user has the uid 1, 3 or 5
[END]

[loginUser('*') == false]
  page.10.value = You are logged out!
[END]
Copied!

usergroup

usergroup

usergroup
Parameter

String

type

Boolean

Value or constraint, wildcard or RegExp possible.

Allows to check whether current user (FE or BE) is part of the expected usergroup.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
# Any usergroup
[usergroup("*")]
  page.10.value = You are logged in and belong to some usergroup.
[END]

[usergroup("12")]
  page.10.value = You are in the usergroup with uid 12.
[END]

[usergroup("12,15,18")]
  page.10.value = You are in the usergroup with uid 12, 15 or 18.
[END]
Copied!

session()

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/TypoScript/setup.typoscript
[session("foo|bar") == 1234567]
Copied!

site()

site()

site()
Parameter

String

type

Mixed

Get a value from the site configuration, or null, if no site was found or the property does not exists.

Available Information:

site("identifier")
Returns the identifier of current site as string.
site("base")
Returns the base of current site as string.
site("rootPageId")
Returns the root page uid of current site as integer.
site("languages")
Returns array of available languages for current site. For deeper information, see siteLanguage().
site("allLanguages")
Returns an array of available and unavailable languages for the current site. For deeper information, see siteLanguage().
site("defaultLanguage")
Returns the default language for current site. For deeper information, see siteLanguage().
site("configuration")
Returns an array with all available configuration for current site.

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[site("identifier") == "typo395"]
Copied!

Matches if site base host:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[site("base").getHost() == "www.example.org"]
Copied!

Base path:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[site("base").getPath() == "/"]
Copied!

Rootpage uid:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[site("rootPageId") == 1]
Copied!

Configuration property:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[traverse(site("configuration"), "myCustomProperty") == true]
Copied!

siteLanguage()

siteLanguage()

siteLanguage()
Parameter

String

type

Mixed

Get a value from the site language configuration, or null if no site was found or property not exists.

Available information:

  • siteLanguage("languageId")
  • siteLanguage("locale")
  • siteLanguage("base")
  • siteLanguage("title")
  • siteLanguage("navigationTitle")
  • siteLanguage("flagIdentifier")
  • siteLanguage("typo3Language") : default or 2 letter language code
  • siteLanguage("twoLetterIsoCode") : 2 letter language code
  • siteLanguage("hreflang")
  • siteLanguage("direction")
  • siteLanguage("fallbackType")
  • siteLanguage("fallbackLanguageIds")

Example:

EXT:site_package/Configuration/TypoScript/setup.typoscript
[siteLanguage("locale") == "de_CH"]
  page.10.value = This site has the locale "de_CH"
[END]

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