·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> 网站建设开发 >> php网站开发 >> smarty 换行实例 表格换行

smarty 换行实例 表格换行

作者:佚名      php网站开发编辑:admin      更新时间:2022-07-23
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>