{foreach from=$list key="j" item="listCell"} 
  {if $j>=15 } {* 想跳出循环 *} {/if}{/foreach}有跳出循环语句吗?

解决方案 »

  1.   

    一般这种情况我都是在给assign前就把数据整理好了,然后再赋值给smarty的去页面循环显示的。。
      

  2.   

    {foreach from=$list key="j" item="listCell"}  
      {if $j>=15 } {* break; *} {/if}{/foreach}
      

  3.   

    {foreach name=foo item=listCell from=$list}
    {if $smarty.foreach.foo.iteration>15} 
    {break}
    {/if}
    {/foreach}
      

  4.   

    看你乍样跳吧
    continue
    break 
    两个都可以。另外:楼上的拼错了吧??
      

  5.   

    弱弱的问一声: 在smarty里有continue,break吗? 你们大家用过吗?俺试了continue,break都不行啊!在manual↓也没找到
    http://www.smarty.net/manual/en/language.function.foreach.php
      

  6.   

    代码都贴出来了 怎么可能不行呢   3L的代码就可以 
    不过{if $j>=15 }  ==> {if $j>=15}
      

  7.   

    向lz道歉!!!
    3L的不可以 我之前测试错误
      

  8.   

    smarty不可以用break
    理由是不需要
    因为逻辑控制应该在php侧完成 tpl这边不需要的数据应该在php侧就把它剔除出去 否则逻辑显示的分离就等于没做到
      

  9.   

    可能是我写的有问题吧,我重新写给你看看{foreach name=foo item=listCell from=$list}
    {if $smarty.foreach.foo.iteration>15} //$smarty.foreach.foo.iteration代表foreach循环次数
    {*这里是你的语句*}
    {/if}
    {/foreach}
      

  10.   

    http://www.smarty.net/forums/viewtopic.php?p=54883
    看2 3L的回答
      

  11.   

    谢谢诸位!看来smarty的逻辑功能比较弱,俺再修改PHP的赋值...