[TYPO3-mvc] fluid: adding own variables [discussion]

Sebastian KurfŸürst sebastian at typo3.org
Fri Jul 17 08:10:17 CEST 2009


Hi Christian,

> Today was the first day I used Fluid. And let me say - I really love it. 
> It's simple, easy to learn and powerfull.
> 
> But there is one thing I miss: (not the "it's great, but"-but, more of 
> the "i-love-it-so-much-i-want-to-make-it-even-better"-but)
:-)

> So it would be nice to have an opportunity to create own variables on 
> runtime in the template. Something like this:

So far, we explicitely decided _not_ to add something like a register - 
i.e. that a ViewHelper has to clean up all variables he has added to the 
View when the tag closes. This is done as a security precaution, as very 
very many strange things can happen otherwise (as variables are not 
allowed to be overridden, for the same reason).

What we have, though, is an "f:alias" viewHelper which aliases certain 
variables or expressions to new names inside its tags.
<f:alias map="{foo:bar, hu:hi}">
// here, {foo} and {hu} will be available
</f:alias>
// here not.


> Have there been any discussions or ideas on this concern?
What about implementing a "toggle" ViewHelper?

> The problem I see this far is, that (afaik) ViewHelpers don't know their 
> parents, or do they?
> (otherwise I would have implemented the ViewHelpers right away)
That is correct for a specific reason: To make recursion work, it is not 
enough to just know your parent, instead, you have to turn it "upside 
down" - this is, a parent can know its children.

However, for passing data from one ViewHelper to another, there is the 
ViewHelperVariableContainer, which can be used for this. See f.e. 
Tx_Fluid_ViewHelpers_FormViewHelper ans 
Tx_Fluid_ViewHelpers_Form_AbstractFormViewHelper as an example for its 
usage and ask here if there are any questions :-)


Greets, and thanks for trying out Fluid!
Sebastian


More information about the TYPO3-project-typo3v4mvc mailing list