首页 > 学院 > 开发设计 > 正文

smarty 换行实例 表格换行

2019-11-15 01:58:41
字体:
来源:转载
供稿:网友
smarty 换行实例 表格换行

在 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>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表