Site settings
Site settings receive a type, a default value and documentation through site settings definitions.
They are intended for application-level values that vary between sites but are still part of a documented extension contract. A setting is therefore more than a YAML key: the providing set defines what the key means, which type it accepts and which value is safe when an integrator does not configure it.
The extension that introduces a setting MUST also own and provide that definition. Other sets and sites may override the value, but they do not take ownership of the contract.
Important
Define every setting in an active site set before reading or overriding it.
An entry in settings. does not create a definition. Only a
defined setting is guaranteed to be available under its documented
identifier, validated and converted to its declared type, supplied with a
default value and shown in the site settings editor.
TYPO3 retains anonymous values from legacy setting trees without a definition for backward compatibility. They are not a public configuration contract and should not be used by new code.
On this page
Using site settings
Access defined site settings through:
- the \TYPO3\CMS\Core\Site\Entity\Site object in frontend and backend context using PHP
- the siteSettings key of the data function in TypoScript
- constants in TypoScript or page TSconfig
- the PAGEVIEW Fluid variable
{settings.as part of the resolved TypoScript settingsmy Setting Key} - variables such as
{site.in Fluid templates when using theconfiguration. settings. my Setting Key} Sitedata processor; see Using site configuration in TypoScript and Fluid templates.Processor
Use them for values that vary by site, such as storage page IDs or feature-specific presentation options.
Storing site setting values
The site settings editor stores site-specific values in
config/. TYPO3 creates the file when it is
needed.
Important
Always use a flat YAML map for new settings. files. Each key
must be the complete setting identifier. Do not use the legacy nested-tree
representation for new configuration.
For example:
myExtension.categoryPid: 42
myExtension.detailPagePid: 7
TYPO3 still reads the nested-tree representation for backward compatibility.
A map can represent foo. and foo. at the same time, while a YAML
tree cannot use foo. as both a value and a parent node. The site settings
editor also writes defined settings as a map.
Older site configurations may contain an inline settings key in
config.. Inline settings and settings. are alternative
sources, not two layers: as soon as settings. exists, TYPO3 uses it
instead of the inline values.
Note
You can use imports in settings.. However, as soon as you save
changes in the site settings editor, TYPO3 rewrites the file and all
imports will be removed.
Store shared values in a set's
Configuration/. The editor does not modify
this file. Site-specific values in
config/ take precedence.
Choosing the right layer
Where a value belongs depends on who should own it:
- Definition default
- Use the
defaultinsettings.for the reusable, safe value supplied by the extension. Every defined setting needs this value.definitions. yaml - Set override
- Use
Configuration/for a preset shared by every site that enables the set. A site package commonly uses this layer to adapt extension defaults to a project.Sets/<my_ set>/ settings. yaml - Site override
- Use
config/, usually through the site settings editor, when the value belongs to one site.sites/<my_ site>/ settings. yaml
These layers change the value, not the definition. The definition must come from an active set in all three cases.
How a setting value is resolved
TYPO3 starts with the definition's default. It then applies values from active sets in resolved dependency order, so a set can adapt a setting from an earlier dependency. Finally, the site-specific value takes precedence:
definition default
-> active set overrides
-> config/sites/<my_site>/settings.yaml
After composing the effective value, TYPO3 validates and converts it according to the definition. Without a definition, TYPO3 cannot guarantee the identifier, type or fallback value, which is why undefined values must not be used as a new configuration API.
Defining and overriding site settings
First define the setting in a set that is active for the site:
settings:
myExtension.categoryPid:
label: 'Category storage page'
description: 'Page that stores the category records.'
type: page
default: 0
Then override the defined setting in the site's settings.:
Note
The second setting in this example fills a constant of
EXT:felogin via site settings
(
styles.). Its definition is provided by
the active typo3/ site set.
The first setting is owned by the example extension. The second demonstrates that a site may also override a setting defined by another active set; it does not need to repeat that definition.
Accessing site settings in PHP and Fluid
In PHP you can access the
Site
from the
Site
object via
get:
$categoryPid = $site->getSettings()->get('myExtension.categoryPid');
See Accessing the current site object for ways to retrieve the site object.
Site settings in Extbase Fluid plugins
Site settings are not injected automatically into Extbase controllers or plugin settings. Pass them to the plugin through TypoScript or make the site object available in the controller.
To make the site settings available to all templates in your controller
you can override method Abstract and assign
the site to the view:
<?php
declare(strict_types=1);
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
class ExampleController extends ActionController
{
public function initializeView(): void
{
$this->view->assignMultiple([
'site' => $this->request->getAttribute('site'),
]);
}
public function indexAction(): ResponseInterface
{
// Variable '{site}' was assigned in initializeView().
return $this->htmlResponse();
}
}
You can then use the variable {site. to access the site settings:
Site settings in page TSconfig or TypoScript
TYPO3 exposes the effective value of a site setting, not its definition. It first composes the default and all applicable overrides as described in How a setting value is resolved. Scalar values are then added to the TypoScript constants with exactly the same identifier as the setting.
The definition remains the contract behind that value. Its metadata, such as
label, description and type, is not available as TypoScript. Consequently,
TypoScript should only read identifiers whose definitions are provided by an
active set. Anonymous values may still be exposed for backward compatibility,
but they are not a supported configuration API.
Pass a setting to TypoScript
This example passes a page ID from a site setting to an Extbase plugin. The
extension has already defined my and the site has
overridden it to 658 in Defining and overriding site settings.
After TYPO3 has resolved the setting, the identifier is available as the
TypoScript constant
{$my. It can be assigned
to any scalar TypoScript property:
plugin.tx_myextension.settings.categoryPid = {$myExtension.categoryPid}
With the site override above, the parsed value of
plugin. is 658. If the site
does not override it, the definition's default value 0 is used. A default in
constants. with the same identifier does not win: every
defined setting already supplies a value and overrides typoscript constants.
The same constant is available in page TSconfig. This makes one defined setting usable by both frontend rendering and backend form configuration:
// store tx_ext_data records on the given storage page by default (e.g. through IRRE)
TCAdefaults.tx_ext_data.pid = {$myExtension.categoryPid}
// load category selection for plugin from our dedicated storage page
TCEFORM.tt_content.pi_flexform.ext_pi1.sDEF.categories.PAGE_TSCONFIG_ID = {$myExtension.categoryPid}
Read a setting with the TypoScript data function
In frontend TypoScript, a content object can read the setting directly from the current site instead of using constant substitution:
lib.categoryPid = TEXT
lib.categoryPid {
data = siteSettings:myExtension.categoryPid
}
Use
{$my when a value must be inserted into
the TypoScript configuration while it is parsed, or when it is needed in page
TSconfig. Use
data = site when a
frontend content object supports the data function and should read from the current site at runtime.
Both forms use the exact, case-sensitive setting identifier.
When a page is rendered with PAGEVIEW, the
complete resolved TypoScript settings tree is available in Fluid as
{settings}
. Site settings therefore appear under their dotted path,
for example
{settings.. This variable contains
all TypoScript settings, however, not only Site Settings. A later value from the
site's constants. or a
sys_ record can differ
from the value returned by
$site->get.
Avoid common pitfalls
- Installed does not mean active
- Installing the providing extension makes its set available, but the
definition contributes to a site only when that site activates the set
directly or through a dependency. If a constant is not substituted, first
check the site's
dependenciesinconfig..yaml - Constants are text substitutions
- Site settings are validated and converted according to their definition,
but a TypoScript constant is inserted as source text. The original PHP type
does not survive constant substitution. In particular, a Boolean
truebecomes1andfalsebecomes an empty value. Use the value in a context that applies the expected TypoScript type conversion. - Lists are not single constants
- A setting of type
stringlistis an array. TYPO3 exposes its scalar entries as flattened constants such as{$my; it does not create one usableExtension. allowed Hosts. 0} {$myvalue for the complete list. Read structured settings through the Site Settings API in PHP or Fluid instead of depending on numeric constant names.Extension. allowed Hosts} - Multiline values are not safe constant values
- TYPO3 generates one constant assignment per scalar setting. A line break in
a
textvalue therefore becomes a line break in the generated TypoScript source. Read multiline content directly through the Site Settings API rather than substituting it as a constant. - Identifiers are exact
{$myextension.andcategory Pid} {$myare different constants. Keep the vendor or extension prefix and casing consistent in the definition, all overrides and every consumer.Extension. category Pid} - Dotted paths do not define their parents
- A definition for
mydoes not also defineExtension. features. preview myorExtension. features my. Each identifier that forms part of the public configuration API needs its own definition. Conversely, the map representation inExtension settings.allows separately definedyaml foo.andbar foo.to coexist.bar. baz
Know which value wins
Within a site TypoScript provider, TYPO3 loads set constants first, then adds
the effective site settings as constants, followed by the site's own
constants.. Constants from
sys_ records are
applied afterwards. A later value with the same identifier overrides an earlier
one.
Note
In simplified form, the relevant order is:
- Configuration from $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants']
constants.from active setstyposcript - Effective site setting values
- The site's
constants.typoscript - Constants from
sys_database recordstemplate
When site sets and
sys_ records are combined, also observe
the Clear flags described in
Site set TypoScript. They can clear TypoScript that was provided by
the site and its sets.