The first and last buttons in CLinkPager are always given the class "hidden".
This is due to the logic used to determine their hidden state which in both cases always evaluates true.
Changing the logic to the same as used for the Previous and Next buttons gets them working.
Snippets from CLinkPager::createPageButtons()
Current (Yii 1.0.9) code
// first page
$buttons[]=$this->createPageButton($this->firstPageLabel,0,self::CSS_FIRST_PAGE,$beginPage<=0,false);
|
|
// last page
$buttons[]=$this->createPageButton($this->lastPageLabel,$pageCount-1,self::CSS_LAST_PAGE,$endPage>=$pageCount-1,false);
Altered code
// first page
$buttons[]=$this->createPageButton($this->firstPageLabel,0,self::CSS_FIRST_PAGE,$currentPage<=0,false);
|
|
// last page
$buttons[]=$this->createPageButton($this->lastPageLabel,$pageCount-1,self::CSS_LAST_PAGE,$currentPage>=$pageCount-1,false);
[/code]
Page 1 of 1
CLInkPager First and Last buttons
#3
Posted 18 October 2009 - 02:54 PM
The original code should be correct. $beginPage and $endPage here mean the first and last pages currently shown in the page buttons.
Therefore, the "first page" button will be hidden if the first page button is 1.
Note that the default css style coming with the pager set the first and last page buttons to be "display: none". You may want to override them if you want to show them.
Therefore, the "first page" button will be hidden if the first page button is 1.
Note that the default css style coming with the pager set the first and last page buttons to be "display: none". You may want to override them if you want to show them.
#4
Posted 18 December 2011 - 11:30 AM
qiang, on 18 October 2009 - 02:54 PM, said:
Note that the default css style coming with the pager set the first and last page buttons to be "display: none". You may want to override them if you want to show them.
How do I override the css provided by the standard component? I added
ul.yiiPager .first, ul.yiiPager .last {
display: inline;
}in main.php, but since pager.css comes last when the page is rendered, my modification is overriden again.
... Morpheus: What is "real"? How do you define "real"? If you 're talking about what you can feel, what you can smell, what you can taste and see, then "real" is simply electrical signals interpreted by your brain...
#5
Posted 18 December 2011 - 12:13 PM
What I do - since I don't want the first and/or last buttons set to hidden - is create my own derived linkpager:
Now, they are not shown at all when they're supposed to be not shown.
class CustomLinkPager extends CLinkPager
{
protected function createPageButton($label,$page,$class,$hidden,$selected)
{
if($hidden || $selected)
$class.=' '.($hidden ? self::CSS_HIDDEN_PAGE : self::CSS_SELECTED_PAGE);
if($hidden)
return '<li class="'.$class.'"></li>';
return '<li class="'.$class.'">'.CHtml::link($label,$this->createPageUrl($page)).'</li>';
}
}
Now, they are not shown at all when they're supposed to be not shown.
"Less noise - more signal"
#6
Posted 11 July 2012 - 12:33 PM
I was able to get the "First" and "Last" links to show up by subclassing CLinkPager and using my own css. Full explanation with code example here: www.benjaminlhaas.com/blog/displaying-yiis-clinkpager-first-and-last-buttons (the forums won't let me post a link)
#7
Posted 18 December 2012 - 03:44 AM
As this questions is bound to come up from time to time, here is the solution:
add to your main.css:
if this does not work change #page to your container div ID
add to your main.css:
#page ul.yiiPager .first,
#page ul.yiiPager .last
{
display: inline;
}if this does not work change #page to your container div ID
Share this topic:
Page 1 of 1

Help












