tinybutstrong的By-Page分页插件使用

淡水河边的原创,转载请保留链接。

看图(基于官方的示例):大小: 16.06 K
尺寸: 500 x 148
浏览: 6 次
点击打开新窗口浏览全图

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代码
  1. <table border="1" align="center" cellpadding="2" cellspacing="0">  
  2.   <tr bgcolor="#CACACA">  
  3.     <td width="40" bgcolor="#CACACA"><strong>N#</strong></td>  
  4.     <td width="100"><strong>Product</strong></td>  
  5.     <td width="100"><strong>Price</strong></td>  
  6.   </tr>  
  7.   <tr bgcolor="#F0F0F0">  
  8.     <td><div align="center"> [blk.#]<br>  
  9.       </div></td>  
  10.     <td> [blk.product;block=tr]  <br>  
  11.     </td>  
  12.     <td><div align="right">[blk.price;frm='0.00']</div></td>  
  13.   </tr>  
  14. </table>  

分页导航表格的html:

XML/HTML代码
  1. <table border="1" align="center" cellpadding="2" cellspacing="0">  
  2.   <tr align="center">  
  3.     <td width="16"><a href="[var..script_name]?PageNum=[nv.first;endpoint;magnet=a;mtype=m+m]">|<</a></td>  
  4.     <td width="16"><a href="[var..script_name]?PageNum=[nv.prev;endpoint;magnet=a;mtype=m+m]"><</a></td>  
  5.     <td width="16"><a href="[var..script_name]?PageNum=[nv.page;block=td;navsize=3;navpos=centred]">[nv.page]</a></td>  
  6.     <td width="16" bgcolor="#C4E1E1"><strong>[nv.page;block=td;currpage]</strong></td>  
  7.     <td width="16"><a href="[var..script_name]?PageNum=[nv.next;endpoint;magnet=a;mtype=m+m]">></a></td>  
  8.     <td width="16"><a href="[var..script_name]?PageNum=[nv.last;endpoint;magnet=a;mtype=m+m]">>|</a></td>  
  9.   </tr>  
  10. </table>  

php代码为:

PHP代码
  1. include_once('tbs_class.php');   
  2. include_once('tbs_plugin_bypage.php'); // Plug-in By-Page   
  3. include_once('tbs_plugin_navbar.php'); // Plug-in Navigation Bar   
  4.   
  5. $data[] = array('product'=>'Tuba'       , 'price'=>100.00);   
  6. $data[] = array('product'=>'Trumpet'    , 'price'=>112.50);   
  7. $data[] = array('product'=>'Trombone'   , 'price'=>169.00);   
  8. $data[] = array('product'=>'Banjo'      , 'price'=>119.00);   
  9. $data[] = array('product'=>'Cymbals'    , 'price'=>67.00);   
  10. $data[] = array('product'=>'Drums'      , 'price'=>269.95);   
  11. $data[] = array('product'=>'Flute'      , 'price'=>39.95);   
  12. $data[] = array('product'=>'Saxophone'  , 'price'=>760.00);   
  13. $data[] = array('product'=>'Piano'      , 'price'=>10995.00);   
  14. $data[] = array('product'=>'Organ'      , 'price'=>700.00);   
  15. $data[] = array('product'=>'Clarinet'   , 'price'=>56.00);   
  16. $data[] = array('product'=>'Guitar'     , 'price'=>215.00);   
  17. $data[] = array('product'=>'Harmonica'  , 'price'=>5.99);   
  18. $data[] = array('product'=>'Bass'       , 'price'=>189.00);   
  19. $data[] = array('product'=>'Harp'       , 'price'=>199.00);   
  20. $data[] = array('product'=>'Violin'     , 'price'=>64.95);   
  21. $data[] = array('product'=>'Bagpipes'   , 'price'=>129.00);   
  22. $data[] = array('product'=>'Ukulele'    , 'price'=>48.00);   
  23.   
  24. // Default value   
  25. if (!isset($_GET)) $_GET=$HTTP_GET_VARS ;   
  26. if (isset($_GET['PageNum'])) {   
  27.   $PageNum = $_GET['PageNum'];   
  28. else {   
  29.     $PageNum = 1;    
  30. }   
  31.   
  32. // Default value   
  33. if (isset($_GET['RecCnt'])) {   
  34.   $RecCnt = intval($_GET['RecCnt']);   
  35. else {   
  36.     $RecCnt = -1;   
  37. }   
  38.   
  39. $PageSize = 5;   
  40.   
  41. $TBS = new clsTinyButStrong;   
  42. $TBS->LoadTemplate('tbs_us_examples_page.htm');   
  43.   
  44. // Merge the block by page   
  45. $TBS->PlugIn(TBS_BYPAGE,$PageSize,$PageNum,$RecCnt); // Next block will be merged suing By-Page mode.   
  46. $RecCnt = $TBS->MergeBlock('blk',$data);   
  47.   
  48. // Merge the Navigation Bar   
  49. $TBS->PlugIn(TBS_NAVBAR,'nv','',$PageNum,$RecCnt,$PageSize);   
  50.   
  51. $TBS->Show();   

结果:大小: 14.32 K
尺寸: 393 x 225
浏览: 8 次
点击打开新窗口浏览全图

模板中用到的部分变量说明:

var..script_name 当前执行的PHP文件名.

magnet魔术标识,这里是magnet=a,就是当a标签(超链接)值为空的时候,删除链接。但是如果后面加了“mtype=m+m”即变成“magnet=a;mtype=m+m”时,它会保留链接中的内容(m和m中的内容,会意)。

Tags: tinybutstrong, 分页

« 上一篇 | 下一篇 »

只显示10条记录相关文章

Tinybutstrong的视频教程 (浏览: 1574, 评论: 5)
Tinybutstrong的plug-ins进行mysql分页摸索 (浏览: 83, 评论: 0)
使用Tinybutstrong的plug-ins进行mysql分页 (浏览: 1032, 评论: 0)
在tinybutstrong中使用adodb (浏览: 872, 评论: 0)
Tinybutstrong摸索 (浏览: 829, 评论: 0)
tinybutstrong的动态参数查询和子块的运用 (浏览: 963, 评论: 0)
tinybutstrong模板的条件判断用法 (浏览: 1259, 评论: 1)
tinybutstrong(小强)多列显示补遗 (浏览: 997, 评论: 0)
只需两个参数的一个通用分页类(未测) (浏览: 1102, 评论: 0)
mysql+php分页类(已测) (浏览: 1604, 评论: 1)

Trackbacks

点击获得Trackback地址,Encode: UTF-8 点击获得Trackback地址,Encode: GB2312 or GBK 点击获得Trackback地址,Encode: BIG5

发表评论

评论内容 (必填):