Base Variants

In Site Handling base variants represent different bases for a web site depending on a specified condition. For example a “live” base URL might be https://example.org but on local machine it’s https://example.test as a domain - that’s when variants are used.

Base variants exist for languages, too. Currently these can only be defined through the respective *.yml file, there is no UI available yet.

Variants consist of two parts:

  • a base to use for this variant
  • a condition that decides when this variant shall be active

Conditions are based on Symfony Expression Language and allow flexible conditions. For example:

applicationContext == "Development"

would define a base variant to use in Development context.

Add a base variant

A configured base variant for development context.

Hint

For those coming from earlier TYPO3 versions: With site handling, there is no need for sys_domain records anymore! :)

See also

Read Application Context for more information on how to set the application context.

The following variables and functions are available in addition to the default Symfony functionality:

Example

rootPageId: 1
base: 'https://www.example.com/'
baseVariants:
  -
    base: 'https://example.local/'
    condition: 'applicationContext == "Development"'
  -
    base: 'https://staging.example.com/'
    condition: 'applicationContext == "Production/Sydney"'
  -
    base: 'https://testing.example.com/'
    condition: 'applicationContext == "Testing/Paris"'
languages:
  -
    title: 'Global'
    enabled: true
    languageId: '0'
    base: /
    typo3Language: default
    locale: en_UK.UTF-8
    iso-639-1: en
    navigationTitle: English
    hreflang: gb-en
    direction: ''
    flag: gb
  -
    title: 'DE'
    enabled: true
    languageId: '1'
    base: https://example.de/'
    baseVariants:
      -
        base: 'https://de.example.local/'
        condition: 'applicationContext == "Development"'
      -
        base: 'https://staging.example.de/'
        condition: 'applicationContext == "Production/Sydney"'
      -
        base: 'https://testing.example.de/'
        condition: 'applicationContext == "Testing/Paris"'
    typo3Language: de
    locale: de_DE.UTF-8
    iso-639-1: de
    navigationTitle: Deutsch
    hreflang: de-de
    direction: ''
    fallbackType: strict
    flag: de

Properties

typo3.version

Datatype
string
Description
The current TYPO3 version
Example
9.5.0

typo3.branch

Datatype
string
Description
The current TYPO3 branch
Example
9.5

typo3.devIpMask

Datatype
string
Description
The configured devIpMask taken from $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']
Example
77.176.160.*

applicationContext

Datatype
string
Description
The current application context
Example
Development

Functions

All functions from TYPO3s DefaultFunctionsProvider are available:

ip

Datatype
string
Description
Match an IP address, value or regex, wildcards possible. Special value: devIp for matching devIpMask.
Example
ip("77.176.160.*")

compatVersion

Datatype
string
Description
Match a TYPO3 version
Example
compatVersion("9.5.0"), compatVersion("9.4")

like

Datatype
string
Description
Comparison function to compare two strings. The first parameter is the “haystack”, the second the “needle”. Wildcards are allowed.
Example
like("foobarbaz", "*bar*")

getenv

Datatype
string
Description
Wrapper for PHPs getenv() function. Allows accessing environment variables.
Example
getenv("TYPO3_BASE_URL")