Frontend TypoScript

New in version 12.1

This request attribute obsoletes the usage of \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController->tmpl.

The frontend.typoscript frontend request attribute provides access to the \TYPO3\CMS\Core\TypoScript\FrontendTypoScript object. It contains the calculated TypoScript settings (formerly constants) and sometimes setup, depending on page cache status.

When a content object or plugin (plugins are content objects as well) needs the current TypoScript, it can retrieve it using this API:

// Substitution of $GLOBALS['TSFE']->tmpl->setup
$fullTypoScript = $request->getAttribute('frontend.typoscript')
    ->getSetupArray();
Copied!

API

class \TYPO3\CMS\Core\TypoScript\ FrontendTypoScript

This class contains the TypoScript set up by the PrepareTypoScriptFrontendRendering Frontend middleware. It can be accessed in content objects:

$frontendTypoScript = $request->getAttribute('frontend.typoscript');

getFlatSettings ( )

This is always set up by the middleware: Current settings (aka "TypoScript constants") are needed for page cache identifier calculation.

This is a "flattened" array of all settings, as example, consider these settings TypoScript:

mySettings {
    foo = fooValue
    bar = barValue
}
Copied!

This will result in this array:

$flatSettings = [
    'mySettings.foo' => 'fooValue',
    'mySettings.bar' => 'barValue',
];
Copied!
returntype

array

hasSetup ( )

When a page is retrieved from cache and does not contain COA_INT or USER_INT objects, Frontend TypoScript setup is not calculated, so the AST and the array are not set.

Calling getSetupTree() or getSetupArray() will then throw an exception.

To avoid the exception, consumers can call hasSetup() beforehand.

Note casual content objects do not need to do this, since setup TypoScript is always set up when content objects need to be calculated.

returntype

bool

getSetupArray ( )

The full Frontend TypoScript array.

This is always set up as soon as the Frontend rendering needs to actually render something and can not get the full content from page cache. This is the case when a page cache entry does not exist, or when the page contains COA_INT or USER_INT objects.

returntype

array