The template which display "None found" if no results with {foreachelse}. php
借助{foreachelse}标记在没有结果时模板输出"None found"字样。 sql
{foreach key=cid item=con from=$results} 数组
<a href="contact.php?contact_id={$cid}"> ide
{$con.name} - {$con.nick}</a><br /> oop
{foreachelse} this
No items were found in the search spa
{/foreach} 索引
index contains the current array index, starting with zero. ci
.index包含当前数组索引,从零开始。 rem
Example 7-10. index example
例 7-10. index示例
{* The header block is output every five rows *}iteration contains the current loop iteration and always starts at one, unlike index. It is incremented by one on each iteration.
iteration包含当前循环次数,与index不一样,从1开始,每次循环增加1。
Example 7-11. iteration and index example
例 7-11. iteration和index示例
first is TRUE if the current {foreach} iteration is the initial one.
first在当前{foreach}循环处于初始位置时值为TRUE(当前 foreach 循环第一次执行时 first 被设置成 true)。
Example 7-12. first property example
例 7-12. first属性示例
{* show LATEST on the first item, otherwise the id *}last is set to TRUE if the current {foreach} iteration is the final one.
last在当前{foreach}循环处于最终位置是值为TRUE(当前 foreach 循环执行到最后一遍时 last 被设置成 true)。
Example 7-13. last property example
例 7-13. last属性示例
{* Add horizontal rule at end of list *}show is used as a parameter to {foreach}. show is a boolean value. If FALSE, the {foreach}will not be displayed. If there is a {foreachelse} present, that will be alternately displayed.
show是{foreach}的参数. show是一个布尔值。若是值为FALSE,{foreach}将不被显示。若是有对应的{foreachelse},将被显示(show 是 foreach 的一个参数. 取值为布尔值 true 或 false. 若是指定为 false 该循环不显示,若是循环指定了foreachelse 子句,该子句显示与否也取决于 show 的取值)。
total contains the number of iterations that this {foreach} will loop. This can be used inside or after the {foreach}.
total包括{foreach}将循环的次数,既能够在{foreach}中使用,也能够在以后使用(total 用于显示循环执行的次数,能够在循环中或循环执行后调用)。
Example 7-14. total property example
例 7-14. total属性示例
{* show rows returned at end *} {* 在结束位置显示行数 *} {foreach from=$items key=part_id item=prod name=foo} {$prod.name><hr/> {if $smarty.foreach.foo.last} <div id="total">{$smarty.foreach.foo.total} items</div> {/if} {foreachelse} ... something else ... {/foreach}