TypoScript provider for sites and sets

New in version 13.1

TYPO3 sites have been enhanced to be able to operate as a TypoScript template provider.

By design, a site TypoScript provider always defines a new scope (root-flag) and does not inherit from parent sites (for example, sites up in the root line). This behavior is not configurable by design, as TypoScript code sharing is intended to be implemented via sharable sets.

Note that sys_template records will still be loaded, but they are optional, and applied after the TypoScript provided by the site.

TypoScript dependencies can be included via set dependencies. The TypoScript definitions included via sets are automatically ordered and deduplicated.

Site as a TypoScript provider

The files setup.typoscript and constants.typoscript (placed next to the site's config.yaml file) will be loaded as TypoScript setup and constants, if available. See also Site handling.

Site dependencies (sets) will be loaded first, that means setup and constants can be overridden on a per-site basis.

Example: A site that depends on a sitepackage

The following site configuration depends on a site set provided by a sitepackage extension.

config/sites/my-site/config.yaml
base: 'http://example.com/'
rootPageId: 1
dependencies:
  - myvendor/my-sitepackage
Copied!

You can place TypoScript constants or setup in files of that name in the same folder like the site configuration:

config/sites/my-site/setup.typoscript
page.headerData {
    50 = TEXT
    50.value = <!-- This is only displayed in the header of site example.org -->
}
Copied!

Same goes for TypoScript constants:

config/sites/my-site/constants.typoscript
page.trackingCode = 123456
Copied!

Set as a TypoScript provider

Set-defined TypoScript can be shipped within a set. The files setup.typoscript and constants.typoscript (placed next to the config.yaml file of the set) will be loaded, if available. They are inserted into the TypoScript chain of the site TypoScript that will be defined by a site that is using sets.

Set constants will always be overruled by site settings. Since site settings always provide a default value, a TypoScript constant will always be overruled by a defined setting. This can be used to provide backward compatibility with TYPO3 v12 in extensions, where constants shall be used in v12, while v13 will always prefer defined site settings.

TypoScript dependencies dependencies to TypoScript in other extensions or other sets are to be included via site sets.

Dependencies are included recursively. Sets are automatically ordered and deduplicated. That means TypoScript will not be loaded multiple times, if a shared dependency is required by multiple sets.

Example: The set of a sitepackage

The following set of a sitepackage depends on the TypoScript and other settings of EXT:fluid_styled_content and EXT:felogin:

EXT:my_sitepackage/Configuration/Sets/MySitepackage/config.yaml
name: myvendor/my-sitepackage
label: My sitepackage set

# Load TypoScript, TSconfig and settings from dependencies
dependencies:
  - typo3/fluid-styled-content
  - typo3/felogin
Copied!

The set can be included as a dependency by other sets or a site configuration.

The set can include further TypoScript constants or setup. It can use @import statements to import TypoScript from another location:

EXT:my_sitepackage/Configuration/Sets/MySitepackage/constants.typoscript
@import 'EXT:my_sitepackage/Configuration/TypoScript/Constants'
Copied!
EXT:my_sitepackage/Configuration/Sets/MySitepackage/setup.typoscript
@import 'EXT:my_sitepackage/Configuration/TypoScript/Setup'
Copied!

Importing TypoScript already contained in other sets should be avoided in favour of using a set dependency.