Reputation: 1481
How to change clistview pagination style.
Clistview by default give First Previous 1 2 3 4... Next Last.
But i want only Previous and Last Button in Pagination style.
What i should do for this change?
Upvotes: 0
Views: 262
Reputation: 326
First I think you should read the document of CListView: and have a look at these properties: template, pager, pagerCssClass. "template" property will define how to display your CListView, and "pager", "pagerCssClass" will define your pagination. There is also an answer on stackoverflow.
Good luck!
Upvotes: 1
Reputation: 4452
you will have to modify the createPageButtons
function of CLinkPager
class of yii framework to do so, there is no shortcut or configuration for it. you will need to create a new component to override or if this is universal requirement through out the project you can change createPageButtons
function of `CLinkPager'with this code.
protected function createPageButtons()
{
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,$this->firstPageCssClass,$currentPage<=0,false);
// prev page
if(($page=$currentPage-1)<0)
$page=0;
$buttons[]=$this->createPageButton($this->prevPageLabel,$page,$this->previousPageCssClass,$currentPage<=0,false);
// next page
if(($page=$currentPage+1)>=$pageCount-1)
$page=$pageCount-1;
$buttons[]=$this->createPageButton($this->nextPageLabel,$page,$this->nextPageCssClass,$currentPage>=$pageCount-1,false);
// last page
$buttons[]=$this->createPageButton($this->lastPageLabel,$pageCount-1,$this->lastPageCssClass,$currentPage>=$pageCount-1,false);
return $buttons;
}
Upvotes: 0