Yii Framework Forum: CPagination enhancment - Yii Framework Forum

Jump to content

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

CPagination enhancment Rate Topic: -----

#1 User is offline   notzippy 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 06-October 08

Posted 02 December 2008 - 12:35 PM

You should be able to specify the "route" (or action) in a pager, but the CPagination.createPageUrl passes an empty argument to the controller making the called action the current action. This may not always be the case - for example when viewing messages in a forum a pager is typically used to display the number of replies to a message and a separate pager is used to display the number of messages in a forum. The action for the pager of the message must go to a different action then that of the pager for the forums' messages.

nz
0

#2 User is offline   notzippy 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 201
  • Joined: 06-October 08

Posted 03 December 2008 - 12:39 PM

Thoughts ? Something as simple as adding the following to CPagination would work...

  public $action = '';

/**
* Creates the URL suitable for pagination.
* @param CController the controller that will create the actual URL
* @param integer the page that the URL should point to.
* @return string the created URL
*/
public function createPageUrl($controller,$page)
{
$params=$_GET;
if($page>0) // page 0 is the default
$params[$this->pageVar]=$page+1;
else
unset($params[$this->pageVar]);
return $controller->createUrl($this->action,$params);
}



nz
0

#3 User is offline   qiang 

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

Posted 03 December 2008 - 01:15 PM

Done. Thanks for the suggestion.
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