I would like to fill an attribute value in a TYPO3 Fluid template with a loop ( f:for
) by using its inline notation:
<div class="one two three">[...]</div>
Does anybody know how to do that?
In the meanwhile I found a solution for my problem. To print all items of an array you could do something like {x -> f:for(each: {0: 'one', 1: 'two', 2: 'three'}, as: 'x')}
. But this will result in: onetwothree
. To fix that the view helper f:if
helps:
<div class="{f:if(condition: i.isLast, then: '{x}', else: '{x} ')
-> f:for(each: {0: 'one', 1: 'two', 2: 'three'}, as: 'x', iteration: 'i')}">
[...]
</div>
您可以进一步调整@witrin的解决方案,并完全内联编写ind:
{f:if(condition: i.isLast, then: '{x}', else: '{x} ') -> f:for(each: '{item.thing}', as: 'x', iteration: 'i')}
I guess you are looking for some 'advanced' array handeling in fluid? have a look at https://fluidtypo3.org/viewhelpers/vhs/master.html .
Please find following inline notations, It helps you lot.
Inline Notation for for loop
Original -> `<f:for each="{data.title}" as="title"> {title} </f:for>`
Inline Notation -> {title -> f:for(each: '{data.title}', as: 'title')}
Inline Notation for date
Date :-> `<f:format.date cldrFormat="MMMM y" forceLocale="{true}" localeFormatType="date">1-{calendar.month}-{calendar.year} 00:00:00</f:format.date>`
Inline Notation :-> {f:format.date(date:'1-{calendar.month}-{calendar.year} 00:00:00',cldrFormat:'MMMM y',localeFormatType: 'date', forceLocale: true)}
so on...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.