[TYPO3-mvc] FLUID: extended loop features

Franz Koch typo3.RemoveForMessage at elements-net.de
Wed Jan 6 19:12:16 CET 2010


Hi guys,

>> if you do:
>> <f:for each="{...}">
>>    <f:cycle values="{0: 'odd', 1: 'even'}" />
>> </f:for>
>> Then it will output "odd" "even" "odd" "even" as often as there are
>> elements in the loop. Isn't that what you want? :-)

how about switching more complex stuff, like subtemplates or stuff. Is 
there a alternative for the inline syntax?

> Then this isn't clear from the examples given in the docs for the view helper.

What doc's are you referring too? I just searched for them about an hour 
ago. All I found for now is [1], but I'm more in favor of a printed 
version of documentations, so I'm looking for a SXW-file (OpenOffice) or 
something. (no docbook please - I can't view or convert those here on 
windows - at least haven't found anything useful yet and tests with OO 
also didn't work although they should support it somehow)

>> (Exactly: The f:cycle has an internal counter which counts how often the
>> specific _instance_ of the f:cycle VH has been called)
>
> For my current use cases this is probably sufficient. Can anyone think of an example where it might
> be useful to let the counter be set from the outside?

yepp - assume you're rendering stuff differently based on some 
if-conditions and are using f:cycle inside both.

<f:for each="{items}" as="{item}">
   <f:if condition="{item.available}">
     <f:then>
       <div class="available {f:cycle values="0: 'odd', 1: 'even'"}">
            Some nested complex html markup here
       </div>
     </f:then>
     <f:else>
       <div class="notAvailable {f:cycle values="0: 'odd', 1: 'even'"}">
           Sorry, Item {item.title} is not available anymore
       </div>
     </f:else>
   </:if>
</f:for>

This is just a example and nothing I currently need (yet) - but there 
are for shure usecases for this. Also when you think about conditional 
rendering of subtemplates and you need to display conditional things 
based on the cycle there.


[1] http://other.garbage-group.de/fluid/
-- 
kind regards,
Franz Koch

---------------------------------------------------
PayPal-Account: 'paypal _at_ elements-net _dot_ de'
---------------------------------------------------


More information about the TYPO3-project-typo3v4mvc mailing list