[FLOW3-general] (FLUID) Assemble TagBasedViewHelper manually

Michael Sauter mail at michaelsauter.net
Thu Feb 4 16:33:24 CET 2010


On 02.02.10 16:18, Michael Sauter wrote:
> On 02.02.10 09:42, Sebastian Kurfürst wrote:
>> Fluid does this in
>> https://svn.typo3.org/TYPO3v4/CoreProjects/MVC/fluid/trunk/Classes/Core/Parser/SyntaxTree/ViewHelperNode.php
>>
>> but I am right now not sure if that is really possible in custom Fluid
>> code, as we have a reference to the syntax tree there, which you will
>> not get from custom Fluid code.
>> However, I also feel that we need to support something like this - I
>> just still am not sure how to integrate this properly with the rest of
>> Fluid.
>
> Thanks for the hint, I'll see if I can use some code from the
> evaluate()-method in ViewHelperNode to build the ViewHelpers in my
> custom Fluid code. I started experimenting with that this morning and at
> least got it to run without exceptions (but the render() method returns
> an empty string). Still have to figure out how to pass in the arguments
> correctly ...

Alright, solved the problem with the arguments (stupid me ...)

Anyway, what I did was to assemble some ViewHelpers in the render() 
method of my own custom ViewHelper. For this to work, I created a class 
that subclasses ViewHelperNode and basically wrote my own evaluate 
method, which I call from my custom ViewHelper.
Although this works for basic ViewHelpers (like Textfields), it doesn't 
for ViewHelpers that have children themselves and somehow this solution 
feels messy (I had to hack some core classes as well ...).

One other idea came to my mind: Maybe it would be better to introduce 
new nodes when parsing the template, not when rendering it. E.g. after 
parsing a ViewHelper, calling a method in it that can inject new nodes 
into the object tree. What do you think ... or is this idea crap? ;) 
Unfortunately I don't understand the whole parsing/rendering process yet ...

- Michael


More information about the FLOW3-general mailing list