Mik*_*ike 2 coldfusion loops mura
任何人都可以看到这个循环有什么问题吗?我不是一个冷血开发者,但我正在为我们缺席的开发人员做点什么.我试图让循环在10次迭代后停止,但它没有发生.我使用的CMS是Mura.谢谢.
<cfset limit = 1>
<cfloop condition="iterator.hasNext()">
<cfif limit LTE 10>
<cfoutput>
<cfset item = iterator.next()>
<tr>
<td>#item.getId()#</td>
<td>#item.getTitle()#</td>
</tr>
</cfoutput>
</cfif>
<cfset limit = limit + 1>
</cfloop>
Run Code Online (Sandbox Code Playgroud)
虽然Ben的回答会的工作,最好的选择就是要告诉村迭代多次迭代如何开始循环之前做.
<cfset iterator.setNextN(10) />
<cfloop condition="iterator.hasNext()">
<cfset item = iterator.next()>
<cfoutput>
<tr>
<td>#item.getId()#</td>
<td>#item.getTitle()#</td>
</tr>
</cfoutput>
</cfloop>
Run Code Online (Sandbox Code Playgroud)
通常它默认为10,因此在您的设置或代码中的某处必须将其设置为更多.