I'm feeding Contentelments into an Extension using Fluid:
<f:for each="{field.children}" as="myObj" iteration="iterator">
{myObj.render -> f:format.raw()}
</f:for>
which is working fine.
Elements look something like this:
<div class="childElement">
<h1>I'm a Caption!</h1>
<p>I'm some text.....</p>
</div>
The Elements are then displayed in a certain way.
Now I want the first Element to have one extra class called "first". The first Element would then look like this:
<div class="childElement first">
<h1>I'm a Caption!</h1>
<p>I'm some text.....</p>
</div>
I tried solving this using an iterator and simply checking if the iterator "isfirst". Something like this:
<f:for each="{field.children}" as="myObj" iteration="iteration">
<f:if condition="iteration.isFirst">
<f:then>
...
But then I still need to insert the class and it anyways feels like there has to be a better way to solve it.
Can someone maybe point me to the right direction?
Edit(Solution):
The accepted answer worked for me after I did the "<div class="childElement">"
-wrapping in the extension rather then in the Child.
My solution looks like this now:
<f:for each="{field.children}" as="myObj" iteration="iterator">
<div class="childElement {f:if(condition:iterator.isFirst, then: ' first')}">
{childDce.render -> f:format.raw()}
</div>
</f:for>