3

名前のリストを含む配列があります。フロントエンドでは、これをリスト形式でリストする必要があります。<ul> and <li>タグの使用。

リストの半分を 1 つの<ul>タグの下に表示し、残りの半分を別の<ul>タグの下に表示する必要があります。

このような:

<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>

<ul>
<li>Four</li>
<li>Five</li>
<li>Six</li>
</ul>

問題は FLUID にあり<ul>、配列が要素の半分をループするときにタグを終了する方法が見つかりませんでした。

私はこのようなことをしたい

<f:for each="{my_array}" as="item">
<li>{item}</li>
<!-- if condition where count=(my_array%2) then use </ul><ul>-->
</f:for>
4

2 に答える 2

8

I think you should get the id in PHP for the element in the middle and then you can use a simple if, like this:

It is a bit extended version of f:for. Here you can check the iteration property. When you use the iteration.index it is the current index of elements. However an elementLimit you have to set.

It is several properties for iteration : isFirst,isLast, isEven, isOdd, total, cycle, index.

Here is an article about it.

UPDATED example:

<f:for each="{my_array}" as="item" iteration="itemIterator">
    <li>{item}</li>
    <f:if condition="{itemIterator.index} = {elementLimit}">
        </ul><ul>
    </f:if>
</f:for>
于 2013-05-15T12:14:36.513 に答える