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

Christian Zenker christian.zenker at 599media.de
Thu Jul 16 21:08:29 CEST 2009


Hi.

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)

Our designer loves zebra-coloring of lists - but I see no way of doing it  
in fluid without the need to double content.
So it would be nice to have an opportunity to create own variables on  
runtime in the template. Something like this:

<ul>
   <f:for each="{0 : 'one', 1 : 'two', 2 : 'three', 3 : 'four'}" as="item"  
key="key">
     <f:register.storage>
       <f:if condition="{key}%2">
         <f:then>
           <f:register.add variables="{'zebra' : 'even', 'foo' : 'bar'}" />
         </f:then>
         <f:else>
           <f:register.add variables="{'zebra' : 'odd', 'foo': 'baz'}" />
         </f:else>
       </f:if>

       <li class="{zebra}">
         {item}
       	...do some more stuff...
       </li>

     </f:register.storage>
   </f:for>
</ul>

The Register_StorageViewHelper manages all variables registered by the  
Register_AddViewHelper's in it and removes the variables afterwards.
If a Register_AddViewHelper is called, it recursively searchs his parents  
for a Register_StorageViewHelper and calls a function there.

Have there been any discussions or ideas on this concern?

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)


Thoughts, comments and ideas welcome.

Christian.


More information about the TYPO3-project-typo3v4mvc mailing list