[TYPO3-mvc] different layout tempaltes for same action/controller
Franz Koch
typo3.RemoveForMessage at elements-net.de
Fri Feb 11 16:19:15 CET 2011
Hi,
> i have a list which i want to render in 3 different tempaltes (normal,
> mini and maxi)
>
> i could manage making 3 sections in the List.html , and choosing the
> "layout" by:
>
> $this->view->setLayoutPathAndFilename(t3lib_extMgm::extPath('myext') .
> 'Resources/Private/Layouts/mini.html');
> or
> $this->view->setLayoutPathAndFilename(t3lib_extMgm::extPath('myext') .
> 'Resources/Private/Layouts/maxi.html');
>
> is this the best way?
I think currently there is no "best" way. Your example is a reliable and
working solution.
> since this "context" is specifig just for the list main controller, and
> Layout folder seems global...
> couldn't i pass to the view the section i want it to use?
>
> something like: $this->view->useSection('mini'); ?
what I do is that I add a switch for the section/partial to use directly
in my template:
$this->view->assign('arg1', $arg1);
$this->view->assign('arg2', $arg2);
$this->view->assign('layout', $layoutToUse);
---- Templates\Model\List.html -------
<f:section name="main">
<f:render section={layout}" arguments="{arg1:arg1, arg2:arg2}" />
</f:section>
<f:section name="layout1">
...
</f:section>
--------------------------------------
The only downside of this is, that you have to pass all needed view
variables manually to the section as arguments like shown in the example.
--
kind regards,
Franz Koch
More information about the TYPO3-project-typo3v4mvc
mailing list