What are TYPO TypoScript conditions, and how do you use them?

What are TYPO TypoScript conditions, and how do you use them?

TYPO3 TypoScript conditions allow you to define logic and control the flow of TypoScript code based on specific conditions (like user group, device type, language, etc.). This feature helps to apply different settings or configurations based on dynamic factors in TYPO3.

1. Syntax for Conditions

Conditions in TypoScript are written in the following format:

Example

[condition]
  # TypoScript properties or objects
[else]
  # Alternative TypoScript properties or objects
[global]

Example Conditions:

  • User Group Condition:

Example

[userGroup = 1]
  # Code for group 1
[else]
  # Code for other groups
[global]

Device Condition (mobile vs desktop):

Example

[device = mobile]
  # Mobile settings
[else]
  # Desktop settings
[global]

Combine Conditions:

Example

[userGroup = 1 && language = 1]
  # Code for group 1 and default language
[global]

Global Fallback:

Example

[global]
  # This applies regardless of condition

Related Questions & Topics