|
深入範本應用:特殊迴圈 |
Ease Template 有兩種另類迴圈處理方式。所謂另類就是可以對迴圈的表格進行換行或是換色彩。在以往的開發中,這些都比較麻煩,但在使用另類迴圈後由页面工程師就可以完成工作。
首先介紹表格換行用法。這裡不單指換行,而且使用者可以根據需求在換行的表格中設定色彩,方便使用者實現特殊需求。
使用幫助: |
用法:{row:2}
陳述式解釋:{row:2,換行內容}
2表示每行顯示2個,如果設定了獨立的換行內容可以設定每行的色彩。
例如:{row:2,#ffffff:#dcdcdc}
另外的使用方法:
<!-- row:2 -->
或者
<!-- row:2,#ffffff:#dcdcdc --> |
|
test_7.php
-
<?php
- include"./template.ease.php";
- $tpl = new template();
- $lists = array('香蕉','茄子','白菜','龍蝦','老虎','獵人','飛機','宇宙');
- $tpl->set_file('test_7');
- $tpl->p();
- ?>
test_7.htm
-
普通換行
- <table border="1" width="100%" bordercolor="#808080" style="border-collapse: collapse">
- <tr>
- <!-- $lists AS $k=>$v -->
- <td>{v}</td>
- {Row:2} <!-- 設定換行數量,2表示一行顯示兩個儲存格 -->
- <!-- END -->
- </tr>
- </table>
- 換行改變色彩
- <table border="1" width="100%" bordercolor="#808080" style="border-collapse: collapse">
- <tr>
- <!-- $lists AS $k=>$v -->
- <td>{v}</td>
- <!-- ROW:2,#ffffff:#dcdcdc -->
- <!-- END -->
- </tr>
- </table>
看到這裡也許妳會問:既然表格能換色彩了,為什麼還要講解換色彩的問題?
主要目的是想讓妳知道如何做到更另類的色彩更換效果,並且配合上麵換行實現色彩變換。
test_8.php
-
<?php
- include"./template.ease.php";
- $tpl = new template();
- $lists = array('香蕉','茄子','白菜','龍蝦','老虎','獵人','飛機','宇宙');
- $tpl->set_file('test_8');
- $tpl->p();
- ?>
下麵的範本介紹了兩種效果。
test_8.htm
-
隔行更換色彩
- <table border="1" width="100%" bordercolor="#808080" style="border-collapse: collapse">
- <!-- $lists AS $k=>$v -->
- <tr>
- <td bgcolor="{color:#dcdcdc,#ffffff}">{_i}.{v}</td>
- </tr>
- <!-- END -->
- </table>
- 結合表格換行並且變更色彩
- <table border="1" width="100%" bordercolor="#808080" style="border-collapse: collapse">
- <tr>
- <!-- $lists AS $k=>$v -->
- <td bgcolor='{color:#FFE1FF,#BBDDFF}'>{_i}.{v}</td>
- <!-- row:2 -->
- <!-- END -->
- </tr>
- </table>
說到這裡迴圈的功能基本上就講完了,後麵我們將講解開發debug及最佳化效率方式。 |
|