|
樣版的寫法如下:
| templates/test4.htm: |
<html> <head> <title>橫向重覆表格測試</title> </head> <body> <table width="500" border="1" cellspacing="0" cellpadding="3"> <tr> <{section name=sec1 loop=$my_array}> <td><{$my_array[sec1].value}></td> <{if $smarty.section.sec1.rownum is div by 2}> </tr> <tr> <{/if}> 数据挖掘研究院 <{/section}> </tr> </table> </body> </html>
|
重點在於 $smarty.section.sec1.rownum 這個 Smarty 變數,在 section 迴圈中這個變數會取得從 1 開始的 索引值,所以當 rownum 能被 2 除盡時,就輸出 </tr><tr> 使表格換列 (注意!是 </tr> 在前面 <tr> 在後面) 。因此數字 2 就是我們在一列中想要呈現的資料筆數。各位可以由此去變化其他不同的呈現方式。 数据挖掘论坛
載入外部內容
|