Blog single

All You Need To Know About TypoScript Conditions With Symfony Expression Language

Did you know, TYPO3 v9.5 LTS the Symfony expression language was introduced in TypoScript conditions? Yeah!! TypoScript is the kind heart of TYPO3 which is getting more powerful by add-ons of the most popular Symfony expression.

Did you know, TYPO3 v9.5 LTS the Symfony expression language was introduced in TypoScript conditions? Yeah!! TypoScript is the kind heart of TYPO3 which is getting more powerful by add-ons of the most popular Symfony expression.

Here I would like to show, How old TypoScript conditions are migrated to brand new Symfony expression language?

When two great OpenSource meet!

TYPO3 + Symfony collaborate together, Cool, huh?

Symfony is a set of reusable PHP components... and PHP is a framework for web projects~

That’s the beauty of Open Source projects and community! TYPO3 is once again proof, It’s kind CMS which works well and can be integrated with other Open Source projects.

The TYPO3 core is working hard to use Symfony components to keep improve the base of TYPO3 CMS solution.

I think, you’ve already heard some of the terminologies like YAML, Routing, Console, etc., which comes from Symfony Framework.

You may be surprised, How many Symfony components are used into TYPO3 CMS? Here is the list:

How current TypoScript conditions?

New TYPO3 learners are sometimes a bit afraid and feel it difficult to deal with TypoScript. But, once you understand the beauty of TypoScript then you will definitely love it.

TypoScript is not a scripting language, It serves more as a kind of API (interface) to configure the underlying PHP code.

So, here is the syntax about currently  how TypoScript conditions are used:

// TypoScript Code
[condition 1] [condition 2]
// True, Write your code here

Using TypoScript conditions, you will have the flexibility to control your TYPO3 templates, layouts, content elements, etc.,

Introducing brand new Symfony Expression Language

The Expression Language provides an engine that compiles and evaluates expressions. An expression is a one-liner that returns a value. Most of the time its value is Boolean type, either true or false.

How does it look inside Symfony?

$symfonyExpressionLanguage>evaluate('1 < 2');
// return true

$symfonyExpressionLanguage>evaluate('not ("Search" matches "/Replace/")'); 
// return true

$symfonyExpressionLanguage>evaluate('11 in 1..10');
// return true

$symfonyExpressionLanguage>evaluate('calendar.getWeekday() == "Monday"'));
// return true on monday, otherwise wrong

You may check out other detailed examples and documentation at

New TypoScript Conditions from TYPO3 9 LTS

The Symfony Expression Language has been introduced from TYPO3 v9.4.

The old syntax is considered as absolute and will be deprecated from v10.

So, it is highly recommended to migrate to Symfony expression language for your new and TYPO3 update/upgrade projects to make sure everything works well in future :)

Download Now: Free TYPO3 Update/Upgrade Kit


Even before the TYPO3 9 release, TypoScript conditions were used with Symfony Expression Language. Here are the samples:

applicationContextReturns the information about current environment eg., production or development.
pageReturns all the properties of the current page
{$theConstant}Returns access of the TypoScript constant
frontend.user.isLoggedInReturns true, if frontend user is logged-in
typo3.versionReturns the version of information of TYPO3


In order to replace all previous TypoScript conditions, TYPO3 also provides functions in addition to the above variables.

date()Returns current date
like("string", "*chat")Returns if the string char is found in a string.
getTSFE()Returns an access to the TypoScript Frontend Controller $GLOBALS[‘TSFE’];
request.getQueryParams()Returns all GET Params.
site()Returns the properties from the Site management module.

Check this release notes to Implement symfony expression language for TypoScript conditions.


Now, Let’s compare between previous TypoScript conditions and Symfony Expression Language.

Site language

// Until TYPO3 v9
[globalVar = GP:L = 1]

// as of TYPO3 9.4 - the L-parameter is omitted, therefore verification of the site configuration

[siteLanguage("languageId") == "1"]

// Next to the Id, you can also query other properties

[siteLanguage("title") == "English"]

Get parameter

// Until TYPO3 v9.3

[globalVar = GP:tx_myext_myplugin|bla > 0]

// from TYPO3 v9.4 (GET parameter or POST parameter)

[(request.getQueryParams()['tx_myext_myplugin'])['bla'] > 0 || 

(request.getParsedBody()['tx_myext_myplugin'])['bla'] > 0]

Layer in the page tree

// Until TYPO3 v9.3
[treeLevel = 0,2] 

// From TYPO3 v9.4 
[tree.level in [0,2]]

Page in root line

// Until TYPO3 v9.3 

[PIDinRootline = 5,10] 

// From TYPO3 v9.4 

[5 in tree.rootLineIds || 10 in tree.rootLineIds]

Page properties

// Until TYPO3 v9.3
[page|backend_layout = 1]

// From TYPO3 v9.4

[page["backend_layout"] == '1']


// Until TYPO3 v9.3
[globalString = IENV:HTTP_HOST = *]

// From TYPO3 v9.4

[like(request.getNormalizedParams().getHttpHost(), '*')]


// Until TYPO3 v9.3
[globalVar = LIT:1 = {$meineTypoScriptKonstante}]

// From TYPO3 v9.4

[{$meineTypoScriptKonstante} == '1']

User logged in the backend

// Until TYPO3 v9.3
[globalVar = TSFE:beUserLogin > 0]

// From TYPO3 v9.4

Is it Friday today?

// Until TYPO3 v9.3
[dayofweek = 5]

// From TYPO3 v9.4
[date("w") == 5]

Do you want TypoScript Conditions with Expression Language?

Until date, to call your own user functions, we call it via [userFun].

[userFunc = \Vendor\Extension\UserFunc\MyUserFunc('foo')]

The ExpressionLanguage can also be extending by registering news methods.

Step 1: Create Configuration/ExpressionLanguage.php in your extension.

Step 2: Register your provider by returning an array of your custom ExpressionLanguage.php.

return [
    'tx_myext_provider' => [

Step 3: Create your custom class to write your code

Take a closer look to TypoScript condition provider ExpressionLanguage from TYPO3 core as below:

class TypoScriptConditionProvider extends AbstractProvider
	    public function __construct()
	        $typo3 = new \stdClass();
	        $typo3->version = TYPO3_version;
	        $typo3->branch = TYPO3_branch;
	        $typo3->devIpMask = trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
	        $this->expressionLanguageVariables = [
	            'request' => GeneralUtility::makeInstance(RequestWrapper::class, $GLOBALS['TYPO3_REQUEST'] ?? null),
             'applicationContext' => (string)GeneralUtility::getApplicationContext(),
            'typo3' => $typo3,
        $this->expressionLanguageProviders = [


  • Keep best practice with using brand new TypoScript conditions using Symfony Expression Language because old will be deprecated from TYPO3 v10.
  • Keep in mind to migrate old TypoScript conditions to new which upgrading your projects.
  • Keep reading documentation to be aware of all new TypoScript conditions.
  • Keep feeling the power and beauty of OpenSource projects and community = TYPO3 + Symfony.

Thank you very much for reading! Feel free to write any suggestion or feedback at below comment box.

You may become my Patreon at I’ll be happy to keep motivated to write cooler TYPO3 blogs :)

Inspiring People To Collaborate! (TYPO3 + Symfony).

Write comment




    No Comments

Want to explore TYPO3 upgrade in depth ?

Checkout our detailed expert blogs on TYPO3 Upgrade

Wie behältst du den Überblick über dein TYPO3-Spiel?

Am besten melden Sie sich für unseren Newsletter mit einer monatlichen Dosis TYPO3 an.

Abonniere jetzt

Ein TYPO3-Preisträger-Agentur