Reputation: 565
Since TYPO3 9.5 LTS suggests to use the Symfony Expression Language for TypoScript conditions.
Old Syntax:
// Matches any applicationContext with a rootContext of "Production", for example "Production/Live" or "Production/Staging":
[applicationContext = Development*]
// Matches any applicationContext starting with "Production/Dev"
[applicationContext = /^Production\/Dev/]
I've tried the following without success:
[applicationContext == "/^Development\/Docker/"]
[applicationContext == "Development*"]
[applicationContext == "Development/*"]
I didn't found any examples. I'm not sure, if the tests for conditions are already based on the expression language. (https://review.typo3.org/#/c/57787/)
Would be nice if someone has an advice how to use the feature to add conditions like before
Upvotes: 2
Views: 1618
Reputation: 9
This regexp matches the exact string "Production" and any string that starts with "Production/", eg "Production/Staging".
Match an applicationContext is "Production" or is starting with "Production/"
[applicationContext matches '#^Production(/|$)#']
Upvotes: -1
Reputation: 565
Production/Dev
"[applicationContext matches '/^Production\\\\\\\\/Dev/']
Why so many backslashes? A backslash (
\
) must be escaped by 4 backslashes (\\\\
) in a string and 8 backslashes (\\\\\\\\
) in a regex in the Symfony Expression Language(Symfony Expression Language acts as the base for TypoScript conditions since TYPO3 9 LTS)
EDIT 2020-02: Using a different regex delimiter makes the readability much better for applicationContext conditions within TYPO3:
Instead of
/
we can use#
as regular expression delimiters.Here are some examples:
Development
" applicationContext[applicationContext matches "#^Development#"]
Production/Dev
"[applicationContext matches "#^Production/Dev#"]
Production/Dev
or Production/Staging
"[applicationContext matches "#^Production/(Dev|Staging)#"]
Production/Live
[applicationContext matches "#^Production/Live#"]
Production/Live
and an active TYPO3 backend user session[applicationContext matches "#^Production/Live#" && getTSFE().isBackendUserLoggedIn()]
Production
"[not (applicationContext matches "#Production#")]
Production/Live/ClusterServer1
"[applicationContext == "Production/Live/ClusterServer1"]
Upvotes: 8
Reputation: 6460
You need to use the matches
comparison operator of the Symfony Expression Language. This way you can use regular expressions for partial matches:
[applicationContext matches "/^Development/"]
This will match any Development
context.
Upvotes: 6