[TYPO3-mvc] How can I give content to a ViewHelper when using alternative syntax?

Claus Due claus at wildside.dk
Fri Aug 3 00:45:22 CEST 2012


Hi Oliver, Valentin,

FYI: you cannot place a Fluid template piece inside some string which is stored in a Fluid variable or is not otherwise explicitly (which usually means manually) parsed as if it were a Fluid template (and as such, the string being parsed would require namespace definitions to be added, support for Layout if one is used etc. etc.). The string would not be rendered even if it was not escaped (that would require horrible two-pass parsing or some trickery).

This means you a) cannot have your ViewHelpers executed and b) cannot reference your variables if you store a piece of Fluid inside something that is output through Fluid but not parsed manually. Bad situation. It's rather a mess to achieve this sort of behavior especially when combined with RTE, because the RTE processing will _always_ damage your syntax due to wanting to encode special chars which include < and >.

You _may_ be able to…

* Create a new ViewHelper which renders child content, then takes that content and renders a StandaloneView - but trust me, this will most likely open up a huge can of worms if you rely on a ControllerContext and will surely hinder performance.
* In the ViewHelper do $standaloneView->assignMultiple($this->templateVariableContainer->getAll());
* $namespaces = '{myext=Tx_MyExt_ViewHelpers}'; // note you must manually add all namespaces as such.
* $standaloneView->setTemplateSource($namespaces . html_entity_decode($this->renderChildren()));
* return html_entity_encode($standaloneView->render());

…which is quite a lot to do just to be able to use a Fluid variable and ViewHelper in a record's field. Any errors, and you destroy the output (unless you catch and treat exceptions - and then output some useful alternative representation without using Fluid which is kind of back to square one).

I'd advise against the above solution - but present it so that it will give you some idea about why what you are trying is not a good idea ;)


Cheers,
Claus


On Aug 3, 2012, at 12:24 AM, Valentin Zickner <typo3 at joan.coderworks.de> wrote:

> Hi,
> 
> On 02.08.2012 17:40, Oliver Salzburg wrote:
>> Given that I had to enter this into an RTE, it is converted to
>> {'Link Text' -&gt; f:link...
> 
> try to disable RTE or use another editor. &gt; is the HTML tag for >. This should not be replaced in this case.
> 
> You can see some examples for this notation here:
> http://forge.typo3.org/projects/typo3v4-mvc/wiki/FAQ#How-can-I-render-localized-dates
> 
> Regards,
> 
> Valentin
> _______________________________________________
> 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