Best 25+ TypoScript Conditions Cheatsheet

in steemit •  last year 

Main (2).jpg

Modern TypoScript Conditions will save you time & effort. In this article, You will find easy guidelines & examples of TypoScript conditions with modern Symfony expression language (in the form of an easy cheat sheet). Since TYPO3 v9.4 LTS, The community introduced a new TypoScript condition from Symfony's expression language component. As an experienced developer, you understand well the importance and power of TypoScript. Let’s explore in-depth about old vs new TypoScript condition, Variables, and Functions of TypoScript, Create custom TypoScript condition, etc.What's Symfony Expression Language?

The ExpressionLanguage component offers an engine capable of compiling and assessing expressions. An expression, typically a concise one-liner, yields a value, primarily but not exclusively Booleans. TYPO3 makes use of the Symfony Expression Language in specific contexts.

// Symfony Expressions
$expressionLanguage = new \Symfony\Component\ExpressionLanguage\ExpressionLanguage();
$expressionLanguage->evaluate('1 + 2'); // 3
$expressionLanguage->evaluate('1 + 2 === 3'); // true
$expressionLanguage->evaluate('1 + 2 < 3'); // false

Old vs New TypoScript Conditions

Let’s quickly check what's the difference between old and new TypoScript conditions using the Symfony expressions language.

How to check TypoScript Conditions?

// TYPO3 <= 9.3 [Condition 1] && [Condition 2]

// TYPO3 >= 9.4
[Condition 1 && Condition 2]

Which one is the Current Language?

// TYPO3 <= 9.3
[globalVar = GP:L = 1]

// TYPO3 >= 9.4
[siteLanguage("languageId") == 1]
[siteLanguage("title") == "English"]
[siteLanguage("locale") == "en_US.UTF-8"]

similarly yopu can find more typo3script conditions here - 21 TypoScript Conditions Cheatsheet

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!