如何检查循环是否在第一次迭代?
我想将一个类添加到列表项但仅添加到第一个列表,而不是所有列表.
<% loop $LatestNews(3) %>
<% if $this->iteratorPos == 0 %>
<li class="left-arrow highlight">$Title</li>
<% else %>
<li>$Title</li>
<% end_if %>
<% end_loop %>
Run Code Online (Sandbox Code Playgroud)
有没有办法实现这个目标?我不想通过javascript这样做.
Zau*_*sch 10
就在这里.
请参阅模板上的SilverStripe文档,位置指示器部分
<% loop $SomeList %>
<% if $First %>
this is the first item<br>
<% else_if $Last %>
this is the last item<br>
<% else %>
this is item number $Pos<br>
<% end_if %>
<% end_loop %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3277 次 |
| 最近记录: |