麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 編程 > PHP > 正文

Yii使用CLinkPager進(jìn)行的分頁(yè)

2020-03-22 20:31:34
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
這篇文章主要介紹了Yii使用CLinkPager分頁(yè)的方法,需要的朋友可以參考下

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

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

具體代碼如下:

 ?php * CLinkPager html' target='_blank'>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.0class 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()
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); // 頁(yè)數(shù)統(tǒng)計(jì) $buttons[]=$this- createTotalButton(($currentPage+1). /{$pageCount} ,self::CSS_TOTAL_PAGE,false,false); // 條數(shù)統(tǒng)計(jì) $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 >

定義CSS樣式

/** * 翻頁(yè)樣式.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:#2b78a3ul.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中操作:

//分頁(yè)操作$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,)); ? 

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,更多相關(guān)內(nèi)容請(qǐng)關(guān)注PHP !

相關(guān)推薦:

yii2組件實(shí)現(xiàn)下拉框帶搜索功能

對(duì)于Yii2.0表關(guān)聯(lián)查詢的分析

如何用yii去掉必填項(xiàng)中的星號(hào)

以上就是Yii使用CLinkPager進(jìn)行的分頁(yè)的詳細(xì)內(nèi)容,PHP教程

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

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 人人舔人人舔 | 九色一区二区 | 欧美性生活区 | 中文字幕国产日韩 | 日本精品婷婷久久爽一下 | 黄色成人短视频 | 欧美日韩精品不卡一区二区三区 | 成人毛片免费 | 美女91视频 | 成人午夜免费看 | 亚洲人成在线播放 | 日韩黄色片免费看 | 午夜视频在线观看免费视频 | 超污视频在线看 | 13一14毛片免费看 | 欧美1—12sexvideos | 羞羞视频免费网站含羞草 | 久久成人综合网 | 操碰 | 老a影视网站在线观看免费 国产精品久久久久久久久久尿 | 黄色av网 | 久草在线视频首页 | 免费观看9x视频网站在线观看 | 长泽雅美av | 成人在线免费小视频 | 国产激情精品一区二区三区 | 免费久久精品 | 国产羞羞视频 | 国产精品一区二区三区99 | 国产精品久久二区 | 成人免费观看49www在线观看 | 羞羞电影网| 久久国产精品系列 | 免费观看黄色影片 | 在线看成人av | japan护士性xxxⅹhd | 国产成人自拍av | 91久久国产综合精品女同国语 | 欧美日穴视频 | 色播视频在线播放 | av免费在线观看不卡 |