Yii Framework Forum: CLInkPager First and Last buttons - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CLInkPager First and Last buttons Rate Topic: -----

#1 User is offline   Yeti 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 98
  • Joined: 30-May 09

Posted 07 September 2009 - 08:47 AM

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]
0

#2 User is offline   piwer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 14
  • Joined: 04-April 09

Posted 16 October 2009 - 04:48 AM

is there any official solution for this problem?
0

#3 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

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.
0

#4 User is offline   GoofyX 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 174
  • Joined: 15-April 09
  • Location:Thessaloniki, Greece

Posted 18 December 2011 - 11:30 AM

View Postqiang, 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...
0

#5 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

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:


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"
0

#6 User is offline   Benjamin Haas 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 25-July 11
  • Location:New York, NY

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)
0

#7 User is offline   Imre 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 29
  • Joined: 30-March 11

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:

#page ul.yiiPager .first,
#page ul.yiiPager .last
{
	display: inline;
}


if this does not work change #page to your container div ID
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users