[TYPO3-mvc] Determine f:layout dynamically
Markus Klein
klein.t3 at mfc-linz.at
Thu Oct 10 14:53:18 CEST 2013
Hi!
It's not so easy. ;-)
My usecase here is to render E-Mails with a Standalone template.
The template shall render HTML and Text E-Mails, hence it should switch the layout.
<f:layout name="{f:if(condition: isHtml, then:'MailHtml', else:'MailText')}" />
I found out that I can fix the problem by inserting the following line int TemplateCompiler line 209:
$initializationPhpCode .= '$self = $this;' . chr(10);
Kind regards
Markus
------------------------------------------------------------
Markus Klein
TYPO3 CMS Active Contributors Team Member
> -----Original Message-----
> From: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-
> project-typo3v4mvc-bounces at lists.typo3.org] On Behalf Of Dominic Garms
> Sent: Thursday, October 10, 2013 1:50 PM
> To: typo3-project-typo3v4mvc at lists.typo3.org
> Subject: Re: [TYPO3-mvc] Determine f:layout dynamically
>
> On 10/10/2013 07:37 PM, Markus Klein wrote:
> > Hi!
> >
> > Is it not possible to have the layout of a template defined dynamically?
> >
> > <f:layout name="{f:if(condition: isSomething, then:'This',
> > else:'That')}" />
> >
> > This code gives Fatal in FE:
> > Fatal error: Call to a member function getViewHelper() on a non-object
> > in
> >
> /.../master/typo3temp/Cache/Code/fluid_template/Standalone_template_
> so
> > urce_d2e755f13089ffbbf3d3e22e204bf68593c7d8fb.php on line 18
> >
> > Line 18 uses $self which is not defined in function 'getLayoutName'.
> >
> > Any idea how to solve that, or is this even a core bug?
> > Tested on current master.
> >
> > Kind regards
> > Markus
> >
> > ------------------------------------------------------------
> > Markus Klein
> > TYPO3 CMS Active Contributors Team Member
> >
> >
> Hi Markus,
>
> Why you don't call the specific section inside of your layout through a
> submitted variable? I would recommend this over your approach to render a
> specific layout. But you have for sure a cache conflict so just clean up your
> typo3temp/Cache folder.
>
> layout.html
> <f:render section="{section}" />
>
> template.html
> <f:section name="A">
> (...)
> </f:section>
>
> <f:section name="B">
> (...)
> </f:section>
>
> Cheers Dominic
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
More information about the TYPO3-project-typo3v4mvc
mailing list