Conditions¶
TSconfig TypoScript conditions offer a way to conditionally change TypoScript based on current context. See the TypoScript syntax condition chapter for the basic syntax of conditions.
It is possible to use TypoScript conditions in both user TSconfig and page TSconfig, just as it is done in frontend TypoScript. The list of available variables and functions is different, though.
The Symfony expression language tends to throw warnings when sub arrays are checked in a condition that do not exist. Use the traverse function to avoid this.
applicationContext¶
- Variable
applicationContext
- Type
String
- Description
Current application context as string. See Application context.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
[applicationContext == "Development"] # Any context that is "Production" or starts with "Production" (eg Production/Staging"). [applicationContext matches "/^Production/"]
page¶
- Variable
page
- Type
Array
- Description
All data of the current page record as array. Only available in page TSconfig, not in user TSconfig.
- 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"]
tree¶
- Variable
tree
- Type
Object
- Description
Object with tree information. Only available in page TSconfig, not in user TSconfig.
tree.level¶
- Variable
tree.level
- Type
Integer
- Description
Current tree level. Only available in page TSconfig, not in user TSconfig.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
# Check if page is on level 0: [tree.level == 0]
tree.pagelayout¶
- Variable
tree.pagelayout
- Type
Integer / String
- Description
Check for the defined backend layout of a page including the inheritance of the field Backend Layout (subpages of this page). Only available in page TSconfig, not in user TSconfig.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
# Use backend_layout records uids [tree.pagelayout == 2] # Use TSconfig provider of backend layouts [tree.pagelayout == "pagets__Home"]
tree.rootLine¶
- Variable
tree.rootLine
- Type
Array
- Description
Array of arrays with uid and pid. Only available in page TSconfig, not in user TSconfig.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
[tree.rootLine[0]["uid"] == 1]
tree.rootLineIds¶
- Variable
tree.rootLineIds
- Type
Array
- Description
An array with UIDs of the rootline. Only available in page TSconfig, not in user TSconfig.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
# Check if page with uid 2 is inside the root line [2 in tree.rootLineIds]
tree.rootLineParentIds¶
- Variable
tree.rootLineParentIds
- Type
Array
- Description
An array with parent UIDs of the root line. Only available in page TSconfig, not in user TSconfig.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
# Check if page with uid 2 is the parent of a page inside the root line [2 in tree.rootLineParentIds]
backend¶
- Variable
backend
- Type
Object
- Description
Object with backend information.
backend.user¶
- Variable
backend.user
- Type
Object
- Description
Object with current backend user information.
backend.user.isAdmin¶
- Variable
backend.user.isAdmin
- Type
Boolean
- Description
True if current user is admin.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
# Evaluates to true if current backend user is administrator [backend.user.isAdmin]
backend.user.isLoggedIn¶
- Variable
backend.user.isLoggedIn
- Type
Boolean
- Description
True if current user is logged in.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
# Evaluates to true if an backend user is logged in [backend.user.isLoggedIn]
backend.user.userId¶
- Variable
backend.user.userId
- Type
Integer
- Description
UID of current user.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
# Evaluates to true if user uid of current logged in backend user is equal to 5 [backend.user.userId == 5]
backend.user.userGroupIds¶
- Variable
backend.user.userGroupList
- Type
array
- Description
Array of user group IDs of the current backend user.
- Context
Frontend, Backend
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
[2 in backend.user.userGroupIds]
backend.user.userGroupList¶
- Variable
backend.user.userGroupList
- Type
String
- Description
Comma list of group UIDs
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
[like(","~backend.user.userGroupList~",", "*,1,*")]
workspace¶
- Variable
workspace
- Type
Object
- Description
object with workspace information
workspace.workspaceId¶
- Variable
.workspaceId
- Type
Integer
- Description
UID of current workspace.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
[workspace.workspaceId == 0]
workspace.isLive¶
- Variable
workspace.isLive
- Type
Boolean
- Description
True if current workspace is live.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
[workspace.isLive]
workspace.isOffline¶
- Variable
workspace.isOffline
- Type
Boolean
- Description
True if current workspace is offline
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
[workspace.isOffline]
typo3¶
- Variable
typo3
- Type
Object
- Description
Object with TYPO3 related information
typo3.version¶
- Variable
typo3.version
- Type
String
- Description
TYPO3 version (e.g. 12.4.0-dev)
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
[typo3.version == "12.4.0"]
typo3.branch¶
- Variable
typo3.branch
- Type
String
- Description
TYPO3 branch (e.g. 12.4)
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
[typo3.branch == "12.4"]
typo3.devIpMask¶
- Variable
typo3.devIpMask
- Type
String
- Description
$GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
[typo3.devIpMask == "203.0.113.6"]
date()¶
- Function
date()
- Parameter
String
- Type
String / Integer
- Description
Get current date in given format. See PHP date function as reference for possible usage.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
# True if day of current month is 7 [date("j") == 7] # True if day of current week is 7 [date("w") == 7] # True if day of current year is 7 [date("z") == 7] # True if current hour is 7 [date("G") == 7]
like()¶
- Function
like()
- Parameter
String, String
- Type
Boolean
- Description
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]+/")]
traverse()¶
- Function
traverse()
- Parameter
Array, String
- Type
Custom
- Description
This function gets a value from an array with arbitrary depth and suppresses 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] [traverse(request.getQueryParams(), 'tx_news_pi1/news') > 0]
compatVersion()¶
- Function
compatVersion()
- Parameter
String
- Type
Boolean
- Description
Compares against the current TYPO3 branch.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
# True if current version is 12.4.x [compatVersion("12.4")] [compatVersion("12.4.0")] [compatVersion("12.4.1")]
feature()¶
- Function
feature()
- Parameter
String
- Description
Provides access to feature toggles current state.
- Example
- EXT:site_package/Configuration/TypoScript/setup.typoscript¶
# True if feature toggle for strict TypoScript syntax is enabled: [feature("TypoScript.strictSyntax") === false]
site()¶
- Function
site
- Parameter
String
- Description
Get value from site configuration, or null if no site was found or property does not exists. Only available in page TSconfig, not available in user TSconfig. 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 array of available and unavailable languages for 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 [site("identifier") == "my_website"] # Match site base host [site("base").getHost() == "www.example.org"] # Match base path [site("base").getPath() == "/"] # Match root page uid [site("rootPageId") == 1] # Match a configuration property [traverse(site("configuration"), "myCustomProperty") == true]