Smarty - foreach loop 10 times and stop

后端 未结 8 2303
执念已碎
执念已碎 2021-02-07 12:31

Im using the following Smarty code:

{foreach from=$entries key=i item=topic}
  {if $topic.topic_style == question}
    
  • 8条回答
    •  醉梦人生
      2021-02-07 13:06

      If you don't want to write smarty plugin, you can do this too:

      {foreach from=$entries key=i item=topic name=foo} 
        {if $smarty.foreach.foo.index == 10} 
             {php}break;{/php}    
        {/if} 
        {if $topic.topic_style == question} 
          
    • {$topic.title}
    • {/if} {/foreach}

    提交回复
    热议问题