[TYPO3-mvc] Fluidtemplate and settings
Christian Kuhn
lolli at schwarzbu.ch
Wed Nov 21 00:34:08 CET 2012
Hey,
On 09/21/2012 12:04 PM, Thomas Skierlo wrote:
> I am currently trying to use the FLUIDTEMPLATE object for my page
> layout, which is working fine as long as I pass everything that might be
> needed later as variables. This is perfectly ok for any kind of content,
> which really is "variable". Besides that I need some data which is site
> specific, like $startUid, $searchUid, to use it in my templates or view
> helpers, like "do something on the start page only".
>
> So I tried to pass them via TS setup and constants:
>
> plugin.tx_portable_layout {
> settings {
> rootUid = 1
> startUid = 2
> searchUid = 3
> }
> }
> I expected to be able to access settings in my templates as
> {settings.rootUid}, but I can't. Template/Layout/Partials pathes are
> used from my setup/constants. How do I assign my settings to be
> available in the view?
FLUIDTEMPLATE is currently not able to do that. I've tried to add a new
content object for this case, but that doesn't work.
At the moment, you need to XLASS the render() method of fluidTemplate
cObj to assign an array to the view, with code similar to this:
if (is_array($conf['settings.'])) {
$typoScriptService =
t3lib_div::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService');
// needs to be adapted for typo3 < 6.0
$settings =
$typoScriptService->convertTypoScriptArrayToPlainArray($conf['settings.']);
$view->assign('settings', $settings);
}
This enables a setup like:
foo = FLUIDTEMPLATE
foo {
file = some file
variables {
bar = TEXT
bar.value = bar
}
settings {
someSetting = someValue
someOtherSetting.bar = {$accessToSomeContant}
}
}
accessExample: {settings.someOtherSetting.bar}
For 6.0 I now have a pending patch that makes this xclass less
intrusive: http://forge.typo3.org/issues/43182
A feature for FLUIDTEMPLATE that adds a settings as array by default to
the view is documented at: http://forge.typo3.org/issues/23853 I'll push
a patch as soon as 6.0 is released, so we will hopefully see this in 6.1.
Regards
Christian
More information about the TYPO3-project-typo3v4mvc
mailing list