淡水河边的原创,转载请保留链接。
In this example, there are [var.RecCnt] records displayed per page of [var.PageSize].
就是说,在这个例子中,共 [var.RecCnt] 条记录,分页显示,每页显示 [var.PageSize] 条。
就是说:总记录模板变量为: [var.RecCnt] ,每页记录变量为: [var.PageSize]
主体的表格的html:
XML/HTML代码
- <table border="1" align="center" cellpadding="2" cellspacing="0">
- <tr bgcolor="#CACACA">
- <td width="40" bgcolor="#CACACA"><strong>N#</strong></td>
- <td width="100"><strong>Product</strong></td>
- <td width="100"><strong>Price</strong></td>
- </tr>
- <tr bgcolor="#F0F0F0">
- <td><div align="center"> [blk.#]<br>
- </div></td>
- <td> [blk.product;block=tr] <br>
- </td>
- <td><div align="right">[blk.price;frm='0.00']</div></td>
- </tr>
- </table>
分页导航表格的html:
XML/HTML代码
- <table border="1" align="center" cellpadding="2" cellspacing="0">
- <tr align="center">
- <td width="16"><a href="[var..script_name]?PageNum=[nv.first;endpoint;magnet=a;mtype=m+m]">|<</a></td>
- <td width="16"><a href="[var..script_name]?PageNum=[nv.prev;endpoint;magnet=a;mtype=m+m]"><</a></td>
- <td width="16"><a href="[var..script_name]?PageNum=[nv.page;block=td;navsize=3;navpos=centred]">[nv.page]</a></td>
- <td width="16" bgcolor="#C4E1E1"><strong>[nv.page;block=td;currpage]</strong></td>
- <td width="16"><a href="[var..script_name]?PageNum=[nv.next;endpoint;magnet=a;mtype=m+m]">></a></td>
- <td width="16"><a href="[var..script_name]?PageNum=[nv.last;endpoint;magnet=a;mtype=m+m]">>|</a></td>
- </tr>
- </table>
php代码为:
PHP代码
- include_once('tbs_class.php');
- include_once('tbs_plugin_bypage.php'); // Plug-in By-Page
- include_once('tbs_plugin_navbar.php'); // Plug-in Navigation Bar
- $data[] = array('product'=>'Tuba' , 'price'=>100.00);
- $data[] = array('product'=>'Trumpet' , 'price'=>112.50);
- $data[] = array('product'=>'Trombone' , 'price'=>169.00);
- $data[] = array('product'=>'Banjo' , 'price'=>119.00);
- $data[] = array('product'=>'Cymbals' , 'price'=>67.00);
- $data[] = array('product'=>'Drums' , 'price'=>269.95);
- $data[] = array('product'=>'Flute' , 'price'=>39.95);
- $data[] = array('product'=>'Saxophone' , 'price'=>760.00);
- $data[] = array('product'=>'Piano' , 'price'=>10995.00);
- $data[] = array('product'=>'Organ' , 'price'=>700.00);
- $data[] = array('product'=>'Clarinet' , 'price'=>56.00);
- $data[] = array('product'=>'Guitar' , 'price'=>215.00);
- $data[] = array('product'=>'Harmonica' , 'price'=>5.99);
- $data[] = array('product'=>'Bass' , 'price'=>189.00);
- $data[] = array('product'=>'Harp' , 'price'=>199.00);
- $data[] = array('product'=>'Violin' , 'price'=>64.95);
- $data[] = array('product'=>'Bagpipes' , 'price'=>129.00);
- $data[] = array('product'=>'Ukulele' , 'price'=>48.00);
- // Default value
- if (!isset($_GET)) $_GET=$HTTP_GET_VARS ;
- if (isset($_GET['PageNum'])) {
- $PageNum = $_GET['PageNum'];
- } else {
- $PageNum = 1;
- }
- // Default value
- if (isset($_GET['RecCnt'])) {
- $RecCnt = intval($_GET['RecCnt']);
- } else {
- $RecCnt = -1;
- }
- $PageSize = 5;
- $TBS = new clsTinyButStrong;
- $TBS->LoadTemplate('tbs_us_examples_page.htm');
- // Merge the block by page
- $TBS->PlugIn(TBS_BYPAGE,$PageSize,$PageNum,$RecCnt); // Next block will be merged suing By-Page mode.
- $RecCnt = $TBS->MergeBlock('blk',$data);
- // Merge the Navigation Bar
- $TBS->PlugIn(TBS_NAVBAR,'nv','',$PageNum,$RecCnt,$PageSize);
- $TBS->Show();
模板中用到的部分变量说明:
| var..script_name | 当前执行的PHP文件名. |
magnet魔术标识,这里是magnet=a,就是当a标签(超链接)值为空的时候,删除链接。但是如果后面加了“mtype=m+m”即变成“magnet=a;mtype=m+m”时,它会保留链接中的内容(m和m中的内容,会意)。




