天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

Yii使用CLinkPager分頁實例詳解

本文主要講解了YII中使用CLinkPager分頁的方法,這里我們采用物件的形式來定義分頁:

首先在components中自定義LinkPager,并繼承CLinkPager

具體代碼如下:

<?php/** * CLinkPager class file. * * @link http://www.yiiframework.com/ * @copyright Copyright © 2008-2011 Yii Software LLC * @license http://www.yiiframework.com/license/ *//** * CLinkPager displays a list of hyperlinks that lead to different pages of target. * * @version $Id$ * @package system.web.widgets.pagers * @since 1.0 */class LinkPager extends CLinkPager{ const CSS_TOTAL_PAGE='total_page'; const CSS_TOTAL_ROW='total_row';  /** * @var string the text label for the first page button. Defaults to '<< First'. */ public $totalPageLabel; /** * @var string the text label for the last page button. Defaults to 'Last >>'. */ public $totalRowLabel;  /** * Creates the page buttons. * @return array a list of page buttons (in HTML code). */ protected function createPageButtons() {     $this->maxButtonCount=8;     $this->firstPageLabel="首頁";    $this->lastPageLabel='末頁';     $this->nextPageLabel='';    $this->prevPageLabel='';     $this->header="";  if(($pageCount=$this->getPageCount())<=1)  return array();  list($beginPage,$endPage)=$this->getPageRange(); $currentPage=$this->getCurrentPage(false); // currentPage is calculated in getPageRange() $buttons=array();  // first page $buttons[]=$this->createPageButton($this->firstPageLabel,0,self::CSS_FIRST_PAGE,$currentPage<=0,false); // prev page if(($page=$currentPage-1)<0)  $page=0; $buttons[]=$this->createPageButton($this->prevPageLabel,$page,self::CSS_PREVIOUS_PAGE,$currentPage<=0,false); // internal pages for($i=$beginPage;$i<=$endPage;++$i)  $buttons[]=$this->createPageButton($i+1,$i,self::CSS_INTERNAL_PAGE,false,$i==$currentPage); // next page if(($page=$currentPage+1)>=$pageCount-1)  $page=$pageCount-1; $buttons[]=$this->createPageButton($this->nextPageLabel,$page,self::CSS_NEXT_PAGE,$currentPage>=$pageCount-1,false); // last page $buttons[]=$this->createPageButton($this->lastPageLabel,$pageCount-1,self::CSS_LAST_PAGE,$currentPage>=$pageCount-1,false);  // 頁數(shù)統(tǒng)計 $buttons[]=$this->createTotalButton(($currentPage+1)."/{$pageCount}",self::CSS_TOTAL_PAGE,false,false);  // 條數(shù)統(tǒng)計 $buttons[]=$this->createTotalButton("共{$this->getItemCount()}條",self::CSS_TOTAL_ROW,false,false); return $buttons; }  protected function createTotalButton($label,$class,$hidden,$selected) { if($hidden || $selected)  $class.=' '.($hidden ? self::CSS_HIDDEN_PAGE : self::CSS_SELECTED_PAGE); return '<li class="'.$class.'">'.CHtml::label($label,false).'</li>'; }  /** * Registers the needed client scripts (mainly CSS file). */ public function registerClientScript() { if($this->cssFile!==false)  self::registerCssFile($this->cssFile); }  /** * Registers the needed CSS file. * @param string $url the CSS URL. If null, a default CSS URL will be used. */ public static function registerCssFile($url=null) { if($url===null)  $url=CHtml::asset(Yii::getPathOfAlias('application.components.views.LinkPager.pager').'.css'); Yii::app()->getClientScript()->registerCssFile($url); }}

定義CSS樣式

/** * 翻頁樣式 */.page_blue{ margin: 3px; padding: 3px; text-align: center; font: 12px verdana, arial, helvetica, sans-serif;}ul.bluePager,ul.yiiPager{ font-size:11px; border:0; margin:0; padding:0; line-height:100%; display:inline; text-aligin:center;}ul.bluePager li,ul.yiiPager li{ display:inline;}ul.bluePager a:link,ul.yiiPager a:link,ul.bluePager a:visited,ul.yiiPager a:visited,ul.bluePager .total_page label,ul.yiiPager .total_page label,ul.bluePager .total_row label,ul.yiiPager .total_row label{ border: #ddd 1px solid; color: #888888 !important; padding:2px 5px; text-decoration:none;}ul.bluePager .page a,ul.yiiPager .page a{ font-weight:normal;}ul.bluePager a:hover,ul.yiiPager a:hover{ color:#FFF !important; border:#156a9a 1px solid; background-color:#2b78a3}ul.bluePager .selected a,ul.yiiPager bluePager .selected a{ color:#3aa1d0 !important; border: 1px solid #3aa1d0;}ul.bluePager .selected a:hover,ul.yiiPager .selected a:hover{ color:#FFF !important;}ul.bluePager .hidden a,ul.yiiPager .hidden a{ border:solid 1px #DEDEDE; color:#888888;}ul.bluePager .hidden,ul.yiiPager .hidden{ display:none;}

controller中操作:

//分頁操作$criteria=new CDbCriteria;$criteria->order='id DESC';$criteria->select=array('id','uid','username','title','thumb','url','clicks','time','dateline','countfavorite','quality');$criteria->condition=$sql;$total = Video::model()->count($criteria);$pages = new CPagination($total);  $pages->pageSize=self::PAGE_SIZE;$pages->applyLimit($criteria);  $list = Video::model()->findAll($criteria);$title = CommonClass::model()->find(array( 'select'=>array('cname'), 'condition'=>'id = '.$id,));  $this->render('application.views.video.list',array( 'array'=>$array, 'arr'=>$arr, 'result'=>$result, 'list'=>$list, 'pages'=>$pages, 'title'=>$title,));

在views/video/list.php中引用:

<?php $this->widget('LinkPager', array('pages' => $pages,)); ?>

php技術(shù)Yii使用CLinkPager分頁實例詳解,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 国产高清在线露脸一区 | 国产露脸150部国语对白 | 欧美亚洲日韩自拍高清中文 | 亚洲国产区中文在线观看 | 麻豆XXXX乱女少妇精品-百度 | 国产精品AV视频一二三区 | 国内精品偷拍在线观看 | 欧洲老妇人bb | 伊人久99久女女视频精品免 | 5g在视影讯天天5g免费观看 | 国产色精品久久人妻99蜜桃麻豆 | 国产午夜亚洲精品一区 | 啪啪做羞羞事小黄文 | 含羞草免费完整视频在线观看 | 97SE亚洲国产综合自在线不卡 | 我的好妈妈BD免费观看 | 国产精品免费大片 | 2020美女视频黄频大全视频 | 欧洲电影巜肉欲丛林 | 综合激情区视频一区视频二区 | 伦理片天堂eeuss影院2o12 | 激情男女高潮射精AV免费 | 亚洲一区成人 | 轻轻挺进女教师的身体 | 成人a毛片久久免费播放 | 99 久久99久久精品免观看 | 午夜视频在线网站 | 亚洲日韩中文字幕区 | 2019久久这里只精品热在线观看 | 一个人在线观看免费高清视频 | 无颜之月5集全免费看无删除 | 扒开黑女人p大荫蒂老女人 扒开粉嫩的小缝末成年小美女 | 大陆极品少妇内射AAAAAA | 亚洲 自拍 清纯 综合图区 | 纯h超级大尺度小黄文 | 国产野外无码理论片在线观看 | 被男按摩师添的好爽在线直播 | 无码天堂亚洲内射精品课堂 | 色欲AV色欲AV久久麻豆 | 国产成人免费a在线资源 | 欧美国产影院 |