HBcms是一个用Pear框架+Smarty模板引擎构架的cms项目,欢迎大家参与制作Smarty模板

iteration

iteration is used to display the current loop iteration.

iteration 用于显示循环的次数.

NOTE: This is not affected by the section properties start, step and max, unlike the index property. Iteration also starts with 1 instead of 0 like index. rownum is an alias to iteration, they work identical.

注意:iteration 不像index属性受start、step和max属性的影响,该值总是从1开始(index是从0开始的).rownum 是iteration的别名,两者等同.

Example 7-24. section property iteration
Smarty手册范例 7-24. section 的 iteration 属性演示

	{section name=customer loop=$custid start=5 step=2}
	current loop iteration: {$smarty.section.customer.iteration}<br>
	{$smarty.section.customer.index} id: {$custid[customer]}<br>
	{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
	{if $custid[customer.index_next] ne $custid[customer.index]}
 	The customer id will change<br>
	{/if}
	{/section}


	输出结果:

	current loop iteration: 1
	5 id: 1000<br>
 	The customer id will change<br>
	current loop iteration: 2
	7 id: 1001<br>
 	The customer id will change<br>
	current loop iteration: 3
	9 id: 1002<br>
 	The customer id will change<br>
这是一份简单的Smarty手册和Smarty教材,熟练掌握Smarty模板,让您做项目事半功倍