CPagination enhancment


(Notzippy) #1

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


(Notzippy) #2

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


(Qiang Xue) #3

Done. Thanks for the suggestion.