码迷,mamicode.com
首页 > 其他好文 > 详细

smarty 换行实例 表格换行

时间:2014-12-12 16:13:10      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:blog   ar   sp   for   div   art   log   bs   as   

在 foreach 中加入 key=count

<table>  
<{foreach item=item from=$items key=count}>  
<{if $count is div by 2}><tr>
<{/if}>   
<td><{$item.name}></td>   
<td><{$item.summary}></td>   
<td><{$item.date}></td>  
<{if ($count+1) is div by 2}></tr><{/if}>  
<{/foreach}></table>

每行放置三個 <{$item.name}> 後換行 你喜欢换多少就改改参数就可以了!

<table>  
<tr>  
<{foreach item=item from=$items key=count}>      
<td><{$item.name}></td>  
<{if ($count+1) is div by 3}></tr><tr><{/if}>  
<{/foreach}>  
</tr></table>

另一種利用 cycle 來做換行的例子,但只能作到每行兩筆資料就換行的效果 只能换两行


<table>  
<tr>   
<{foreach item=item from=$items}>      
<td><{$item.name}>      
<{cycle values="</td>,</td></tr><tr>"}>   
<{/foreach}>  
</tr>
</table>

smarty 换行实例 表格换行

标签:blog   ar   sp   for   div   art   log   bs   as   

原文地址:http://www.cnblogs.com/wtb123456/p/4159679.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!