pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

整合Booststrap分頁(yè)樣式和ThinkPHP分頁(yè)類

分頁(yè)類修改內(nèi)容:只涉及到樣子生成部分代碼,在原來(lái)每個(gè)A鏈接前加了li,在返回的樣式字符串前加UL,以適合Boostrap的css文件的定義。 Bootstrap的css文件基本保持原狀,只是加了一個(gè)#

分頁(yè)類修改內(nèi)容:只涉及到樣子生成部分代碼,在原來(lái)每個(gè)A鏈接前加了li,在返回的樣式字符串前加UL,以適合Boostrap的css文件的定義。

Bootstrap的css文件基本保持原狀,只是加了一個(gè)#lastspan的樣式定義。
--------------------------------------------------------------------------------

pagination.css

 

  1. .pagination {  
  2.   margin20px 0;  
  3. }  
  4. .pagination ul {  
  5.   display: inline-block;  
  6.   list-style:none;  
  7.   *displayinline;  
  8.   /* IE7 inline-block hack */  
  9.   
  10.   *zoom: 1;  
  11.   margin-left0;  
  12.   margin-bottom0;  
  13.   -webkit-border-radius: 4px;  
  14.   -moz-border-radius: 4px;  
  15.   border-radius: 4px;  
  16.   -webkit-box-shadow: 0 1px 2px rgba(0000.05);  
  17.   -moz-box-shadow: 0 1px 2px rgba(0000.05);  
  18.   box-shadow: 0 1px 2px rgba(0000.05);  
  19. }  
  20. .pagination ul > li {  
  21.   displayinline;  
  22. }  
  23. .pagination ul > li > a,  
  24. .pagination ul > li > span,  
  25. .pagination #lastspan {  
  26.   floatleft;  
  27.   padding4px 12px;  
  28.   line-height20px;  
  29.   text-decorationnone;  
  30.   background-color#ffffff;  
  31.   border1px solid #dddddd;  
  32.   border-left-width0;  
  33. }  
  34. .pagination ul > li > a:hover,  
  35. .pagination ul > li > a:focus,  
  36. .pagination ul > .active > a,  
  37. .pagination ul > .active > span {  
  38.   background-color#f5f5f5;  
  39. }  
  40. .pagination ul > .active > a,  
  41. .pagination ul > .active > span {  
  42.   color#999999;  
  43.   cursordefault;  
  44. }  
  45. .pagination ul > .disabled > span,  
  46. .pagination ul > .disabled > a,  
  47. .pagination ul > .disabled > a:hover,  
  48. .pagination ul > .disabled > a:focus {  
  49.   color#999999;  
  50.   background-colortransparent;  
  51.   cursordefault;  
  52. }  
  53. .pagination ul > li:first-child > a,  
  54. .pagination ul > li:first-child > span {  
  55.   border-left-width1px;  
  56.   -webkit-border-top-left-radius: 4px;  
  57.   -moz-border-radius-topleft: 4px;  
  58.   border-top-left-radius: 4px;  
  59.   -webkit-border-bottom-left-radius: 4px;  
  60.   -moz-border-radius-bottomleft: 4px;  
  61.   border-bottom-left-radius: 4px;  
  62. }  
  63. .pagination ul > li:last-child > a,  
  64. .pagination ul > li:last-child > span,  
  65. .pagination #lastspan {  
  66.   -webkit-border-top-right-radius: 4px;  
  67.   -moz-border-radius-topright: 4px;  
  68.   border-top-right-radius: 4px;  
  69.   -webkit-border-bottom-right-radius: 4px;  
  70.   -moz-border-radius-bottomright: 4px;  
  71.   border-bottom-right-radius: 4px;  
  72. }  
  73. .pagination-centered {  
  74.   text-aligncenter;  
  75. }  
  76. .pagination-right {  
  77.   text-alignright;  
  78. }  
  79. .pagination-large ul > li > a,  
  80. .pagination-large ul > li > span,  
  81. .pagination-large #lastspan{  
  82.   padding11px 19px;  
  83.   font-size17.5px;  
  84. }  
  85. .pagination-large ul > li:first-child > a,  
  86. .pagination-large ul > li:first-child > span {  
  87.   -webkit-border-top-left-radius: 6px;  
  88.   -moz-border-radius-topleft: 6px;  
  89.   border-top-left-radius: 6px;  
  90.   -webkit-border-bottom-left-radius: 6px;  
  91.   -moz-border-radius-bottomleft: 6px;  
  92.   border-bottom-left-radius: 6px;  
  93. }  
  94. .pagination-large ul > li:last-child > a,  
  95. .pagination-large ul > li:last-child > span,  
  96. .pagination-large #lastspan {  
  97.   -webkit-border-top-right-radius: 6px;  
  98.   -moz-border-radius-topright: 6px;  
  99.   border-top-right-radius: 6px;  
  100.   -webkit-border-bottom-right-radius: 6px;  
  101.   -moz-border-radius-bottomright: 6px;  
  102.   border-bottom-right-radius: 6px;  
  103. }  
  104. .pagination-mini ul > li:first-child > a,  
  105. .pagination-small ul > li:first-child > a,  
  106. .pagination-mini ul > li:first-child > span,  
  107. .pagination-small ul > li:first-child > span {  
  108.   -webkit-border-top-left-radius: 3px;  
  109.   -moz-border-radius-topleft: 3px;  
  110.   border-top-left-radius: 3px;  
  111.   -webkit-border-bottom-left-radius: 3px;  
  112.   -moz-border-radius-bottomleft: 3px;  
  113.   border-bottom-left-radius: 3px;  
  114. }  
  115. .pagination-mini ul > li:last-child > a,  
  116. .pagination-small ul > li:last-child > a,  
  117. .pagination-mini ul > li:last-child > span,  
  118. .pagination-small ul > li:last-child > span {  
  119.   -webkit-border-top-right-radius: 3px;  
  120.   -moz-border-radius-topright: 3px;  
  121.   border-top-right-radius: 3px;  
  122.   -webkit-border-bottom-right-radius: 3px;  
  123.   -moz-border-radius-bottomright: 3px;  
  124.   border-bottom-right-radius: 3px;  
  125. }  
  126. .pagination-small ul > li > a,  
  127. .pagination-small ul > li > span {  
  128.   padding2px 10px;  
  129.   font-size11.9px;  
  130. }  
  131. .pagination-mini ul > li > a,  
  132. .pagination-mini ul > li > span {  
  133.   padding0 6px;  
  134.   font-size10.5px;  
  135. }  

-------------------------------------------------------------------------------
Page.class.php

 

 

  1. <?php  
  2. // +----------------------------------------------------------------------  
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]  
  4. // +----------------------------------------------------------------------  
  5. // | Copyright (c) 2009 http://thinkphp.cn All rights reserved.  
  6. // +----------------------------------------------------------------------  
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )  
  8. // +----------------------------------------------------------------------  
  9. // | Author: liu21st <liu21st@gmail.com>  
  10. // |         lanfengye <zibin_5257@163.com>  
  11. // +----------------------------------------------------------------------  
  12. class Page {  
  13.       
  14.     // 分頁(yè)欄每頁(yè)顯示的頁(yè)數(shù)  
  15.     public $rollPage = 5;  
  16.     // 頁(yè)數(shù)跳轉(zhuǎn)時(shí)要帶的參數(shù)  
  17.     public $parameter  ;  
  18.     // 分頁(yè)URL地址  
  19.     public $url     =   '';  
  20.     // 默認(rèn)列表每頁(yè)顯示行數(shù)  
  21.     public $listRows = 20;  
  22.     // 起始行數(shù)  
  23.     public $firstRow    ;  
  24.     // 分頁(yè)總頁(yè)面數(shù)  
  25.     protected $totalPages  ;  
  26.     // 總行數(shù)  
  27.     protected $totalRows  ;  
  28.     // 當(dāng)前頁(yè)數(shù)  
  29.     protected $nowPage    ;  
  30.     // 分頁(yè)的欄的總頁(yè)數(shù)  
  31.     protected $coolPages   ;  
  32.     // 分頁(yè)顯示定制  
  33.     protected $config  =    array('header'=>'條記錄','prev'=>'上一頁(yè)','next'=>'下一頁(yè)','first'=>'第一頁(yè)','last'=>'<span id="lastspan">最后一頁(yè)</span>','theme'=>'<ul><li><span> %totalRow% %header% %nowPage%/%totalPage% 頁(yè)</span></li> %first%  %upPage% %prePage%  %linkPage% %downPage%  %nextPage% %end%</ul>');  
  34.     // 默認(rèn)分頁(yè)變量名  
  35.     protected $varPage;  
  36.     /** 
  37.      * 架構(gòu)函數(shù) 
  38.      * @access public 
  39.      * @param array $totalRows  總的記錄數(shù) 
  40.      * @param array $listRows  每頁(yè)顯示記錄數(shù) 
  41.      * @param array $parameter  分頁(yè)跳轉(zhuǎn)的參數(shù) 
  42.      */  
  43.     public function __construct($totalRows,$listRows='',$parameter='',$url='') {  
  44.         $this->totalRows    =   $totalRows;  
  45.         $this->parameter    =   $parameter;  
  46.         $this->varPage      =   C('VAR_PAGE') ? C('VAR_PAGE') : 'p' ;  
  47.         if(!empty($listRows)) {  
  48.             $this->listRows =   intval($listRows);  
  49.         }  
  50.         $this->totalPages   =   ceil($this->totalRows/$this->listRows);     //總頁(yè)數(shù)  
  51.         $this->coolPages    =   ceil($this->totalPages/$this->rollPage);  
  52.         $this->nowPage      =   !empty($_GET[$this->varPage])?intval($_GET[$this->varPage]):1;  
  53.         if($this->nowPage<1){  
  54.             $this->nowPage  =   1;  
  55.         }elseif(!empty($this->totalPages) && $this->nowPage>$this->totalPages) {  
  56.             $this->nowPage  =   $this->totalPages;  
  57.         }  
  58.         $this->firstRow     =   $this->listRows*($this->nowPage-1);  
  59.         if(!empty($url))    $this->url  =   $url;   
  60.     }  
  61.     public function setConfig($name,$value) {  
  62.         if(isset($this->config[$name])) {  
  63.             $this->config[$name]    =   $value;  
  64.         }  
  65.     }  
  66.     /** 
  67.      * 分頁(yè)顯示輸出 
  68.      * @access public 
  69.      */  
  70.     public function show() {  
  71.         if(0 == $this->totalRows) return '';  
  72.         $p              =   $this->varPage;  
  73.         $nowCoolPage    =   ceil($this->nowPage/$this->rollPage);  
  74.         // 分析分頁(yè)參數(shù)  
  75.         if($this->url){  
  76.             $depr       =   C('URL_PATHINFO_DEPR');  
  77.             $url        =   rtrim(U('/'.$this->url,'',false),$depr).$depr.'__PAGE__';  
  78.         }else{  
  79.             if($this->parameter && is_string($this->parameter)) {  
  80.                 parse_str($this->parameter,$parameter);  
  81.             }elseif(is_array($this->parameter)){  
  82.                 $parameter      =   $this->parameter;  
  83.             }elseif(empty($this->parameter)){  
  84.                 unset($_GET[C('VAR_URL_PARAMS')]);  
  85.                 $var =  !empty($_POST)?$_POST:$_GET;  
  86.                 if(empty($var)) {  
  87.                     $parameter  =   array();  
  88.                 }else{  
  89.                     $parameter  =   $var;  
  90.                 }  
  91.             }  
  92.             $parameter[$p]  =   '__PAGE__';  
  93.             $url            =   U('',$parameter);  
  94.         }  
  95.         //上下翻頁(yè)字符串  
  96.         $upRow          =   $this->nowPage-1;  
  97.         $downRow        =   $this->nowPage+1;  
  98.         if ($upRow>0){  
  99.             $upPage     =    "<li><a href='".str_replace('__PAGE__',$upRow,$url)."'>".$this->config['prev']."</a></li>";  
  100.         }else{  
  101.             $upPage     =    '';  
  102.         }  
  103.         if ($downRow <= $this->totalPages){  
  104.             $downPage   =   "<li><a href='".str_replace('__PAGE__',$downRow,$url)."'>".$this->config['next']."</a></li>";  
  105.         }else{  
  106.             $downPage   =   '';  
  107.         }  
  108.         // << < > >>  
  109.         if($nowCoolPage == 1){  
  110.             $theFirst   =   '';  
  111.             $prePage    =   '';  
  112.         }else{  
  113.             $preRow     =   $this->nowPage-$this->rollPage;  
  114.             $prePage    =   "<li><a href='".str_replace('__PAGE__',$preRow,$url)."' >上".$this->rollPage."頁(yè)</a></li>";  
  115.             $theFirst   =   "<li><a href='".str_replace('__PAGE__',1,$url)."' >".$this->config['first']."</a></li>";  
  116.         }  
  117.         if($nowCoolPage == $this->coolPages){  
  118.             $nextPage   =   '';  
  119.             $theEnd     =   '';  
  120.         }else{  
  121.             $nextRow    =   $this->nowPage+$this->rollPage;  
  122.             $theEndRow  =   $this->totalPages;  
  123.             $nextPage   =   "<li><a href='".str_replace('__PAGE__',$nextRow,$url)."' >下".$this->rollPage."頁(yè)</a></li>";  
  124.             $theEnd     =   "</li><a href='".str_replace('__PAGE__',$theEndRow,$url)."' >".$this->config['last']."</a></li>";  
  125.         }  
  126.         // 1 2 3 4 5  
  127.         $linkPage = "";  
  128.         for($i=1;$i<=$this->rollPage;$i++){  
  129.             $page       =   ($nowCoolPage-1)*$this->rollPage+$i;  
  130.             if($page!=$this->nowPage){  
  131.                 if($page<=$this->totalPages){  
  132.                     $linkPage .= "<li><a href='".str_replace('__PAGE__',$page,$url)."'>".$page."</a></li>";  
  133.                 }else{  
  134.                     break;  
  135.                 }  
  136.             }else{  
  137.                 if($this->totalPages != 1){  
  138.                     $linkPage .= "<li><span class='current'>".$page."</span></li>";  
  139.                 }  
  140.             }  
  141.         }  
  142.         $pageStr     =   str_replace(  
  143.             array('%header%','%nowPage%','%totalRow%','%totalPage%','%upPage%','%downPage%','%first%','%prePage%','%linkPage%','%nextPage%','%end%'),  
  144.             array($this->config['header'],$this->nowPage,$this->totalRows,$this->totalPages,$upPage,$downPage,$theFirst,$prePage,$linkPage,$nextPage,$theEnd),$this->config['theme']);  
  145.         return $pageStr;  
  146.     }  
  147. }  

------------------------------------------------------------------------------
模板中使用:

 

<div class="pagination">{$page}</div> //基本樣式
<div class="pagination pagination-large">{$page}</div>//大號(hào)數(shù)字樣式

 

控制類代碼:

 

  1. $p = new Page ($count,10);     
  2.         $products = $this->product_model->where($where)->order($order.' '.$method)->limit($p->firstRow.','.$p->listRows)->select();  
  3.         $page = $p->show ();     
  4.               
  5.         $this->assign( "page"$page );  

【網(wǎng)站聲明】本站除付費(fèi)源碼經(jīng)過(guò)測(cè)試外,其他素材未做測(cè)試,不保證完整性,網(wǎng)站上部分源碼僅限學(xué)習(xí)交流,請(qǐng)勿用于商業(yè)用途。如損害你的權(quán)益請(qǐng)聯(lián)系客服QQ:2655101040 給予處理,謝謝支持。

相關(guān)文檔推薦

Bootstrap 分頁(yè) 本章將講解 Bootstrap 支持的分頁(yè)特性。分頁(yè)(Pagination),是一種無(wú)序列表,Bootstrap 像處理其他界面元素一樣處理分頁(yè)。 分頁(yè)(Pagination) 下表列出了 Bootstrap 提供的處理分頁(yè)
主站蜘蛛池模板: 专业生物有机肥造粒机,粉状有机肥生产线,槽式翻堆机厂家-郑州华之强重工科技有限公司 | 水平垂直燃烧试验仪-灼热丝试验仪-漏电起痕试验仪-针焰试验仪-塑料材料燃烧检测设备-IP防水试验机 | 小型气象站_便携式自动气象站_校园气象站-竞道气象设备网 | 成都离婚律师|成都结婚律师|成都离婚财产分割律师|成都律师-成都离婚律师网 | 成都中天自动化控制技术有限公司| 无线联网门锁|校园联网门锁|学校智能门锁|公租房智能门锁|保障房管理系统-KEENZY中科易安 | 烟雾净化器-滤筒除尘器-防爆除尘器-除尘器厂家-东莞执信环保科技有限公司 | 电力电子产业网| 细砂提取机,隔膜板框泥浆污泥压滤机,螺旋洗砂机设备,轮式洗砂机械,机制砂,圆锥颚式反击式破碎机,振动筛,滚筒筛,喂料机- 上海重睿环保设备有限公司 | 南京交通事故律师-专打交通事故的南京律师 | 仿古建筑设计-仿古建筑施工-仿古建筑公司-汉匠古建筑设计院 | 护腰带生产厂家_磁石_医用_热压护腰_登山护膝_背姿矫正带_保健护具_医疗护具-衡水港盛 | 等离子表面处理机-等离子表面活化机-真空等离子清洗机-深圳市东信高科自动化设备有限公司 | 苏州工作服定做-工作服定制-工作服厂家网站-尺品服饰科技(苏州)有限公司 | 全自动真空上料机_粉末真空上料机_气动真空上料机-南京奥威环保科技设备有限公司 | 合肥注册公司|合肥代办营业执照、2024注册公司流程 | 屏蔽泵厂家,化工屏蔽泵_维修-淄博泵业 | 物流之家新闻网-最新物流新闻|物流资讯|物流政策|物流网-匡匡奈斯物流科技 | 四川成人高考_四川成考报名网 | 棕刚玉-白刚玉厂家价格_巩义市东翔净水材料厂 | 熔体泵_熔体出料泵_高温熔体泵-郑州海科熔体泵有限公司 | 武汉天安盾电子设备有限公司 - 安盾安检,武汉安检门,武汉安检机,武汉金属探测器,武汉测温安检门,武汉X光行李安检机,武汉防爆罐,武汉车底安全检查,武汉液体探测仪,武汉安检防爆设备 | 棉柔巾代加工_洗脸巾oem_一次性毛巾_浴巾生产厂家-杭州禾壹卫品科技有限公司 | 电磁流量计_智能防腐防爆管道式计量表-金湖凯铭仪表有限公司 | 伺服电机_直流伺服_交流伺服_DD马达_拓达官方网站 | 承插管件_不锈钢承插管件_锻钢高压管件-温州科正阀门管件有限公司 | 复盛空压机配件-空气压缩机-复盛空压机(华北)总代理 | 新型锤式破碎机_新型圆锥式_新型颚式破碎机_反击式打沙机_锤式制砂机_青州建源机械 | 土壤肥料养分速测仪_测土配方施肥仪_土壤养分检测仪-杭州鸣辉科技有限公司 | 电磁铁_推拉电磁铁_机械手电磁吸盘电磁铁厂家-广州思德隆电子公司 | 真空搅拌机-行星搅拌机-双行星动力混合机-广州市番禺区源创化工设备厂 | 超声骨密度仪,双能X射线骨密度仪【起草单位】,骨密度检测仪厂家 - 品源医疗(江苏)有限公司 | 烟台游艇培训,威海游艇培训-烟台市邮轮游艇行业协会 | 柔性测斜仪_滑动测斜仪-广州杰芯科技有限公司 | 无线讲解器-导游讲解器-自助讲解器-分区讲解系统 品牌生产厂家[鹰米讲解-合肥市徽马信息科技有限公司] | 工控机,嵌入式主板,工业主板,arm主板,图像采集卡,poe网卡,朗锐智科 | 应急灯_消防应急灯_应急照明灯_应急灯厂家-大成智慧官网 | 四川职高信息网-初高中、大专、职业技术学校招生信息网 | 锂辉石检测仪器,水泥成分快速分析仪-湘潭宇科分析仪器有限公司 | 塑料异型材_PVC异型材_封边条生产厂家_PC灯罩_防撞扶手_医院扶手价格_东莞市怡美塑胶制品有限公司 | 广东燎了网络科技有限公司官网-网站建设-珠海网络推广-高端营销型外贸网站建设-珠海专业h5建站公司「了了网」 |