Reputation: 51
I'm using Typo3 version 10+ I created a "Site package extension" to make some nice templates and styles (header / footer / etc)
I'm using constants like this (constants.typoscript):
#cat=My website variables//a; type=string; label=Some id value
config.some_id = 123
BE User can edit the constant in BE. To use the constant in fluid template, I use this typoscript code (setup.typoscript)
page = PAGE
page {
typeNum = 0
10 = FLUIDTEMPLATE
10 {
variables {
some_id = TEXT
some_id.value = {$config.some_id}
}
}
...
}
In fluid (footer.html) I use this variable:
<f:link.page pageUid="{some_id}">Some link</f:link.page>
Everything works very nice so far.
Now I'm creating a new extension to output some simple events "Events ext" (list / details)
Now question: is it possible to use this constant (some_id from Site package ext) in the Events extension (List.html) as global variable ?
For some reason I can't see any constants in fluid templates of "Event ext". (empty values)
For both extensions I used the code below and included its configs in Typoscript setup
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
$extensionKey,
'Configuration/TypoScript',
'My ext'
);
Upvotes: 3
Views: 1140
Reputation: 736
Constants defined through page.10.variable are only available for page template, not in your extension template.
But you can easily access this variable in your extension with some TypoScript.
Add this TS - in your my_ext/TypoScript/setup.typoscript or through BE in template setup field :
plugin.tx_you_ext.settings {
some_id = {$config.some_id}
}
And then, you can access the data in your Fluid Template with :
{settings.some_id}
Upvotes: 5