Zend Pagination and Zend Router PDF Print E-mail
Written by Joe   
Friday, 30 April 2010 14:21

Using a static route in conjunction with zend paginator prohibits the pagination links (prev/next etc) from passing the 'page' parameter to the url. Instead use a standard route or regexp, for example: http://some-domain.com/index/users To map this url with a custom route do not use:

$route = new Zend_Controller_Router_Route_Static(
array( 'controller' => 'index', 'action' => 'users' )
$router->addRoute( 'users', $route );

but instead:

$route_users = new Zend_Controller_Router_Route(
'controller' => 'index',
'action' => 'users',
'page' => 1
$router->addRoute( 'targets', $route_users );

This will map requests correctly for: http://some-domain.com/users http://some-domain.com/users/1 http://some-domain.com/users/2 etc and keeps the pagination links working correctly. Omitting the 'page' value from the array means a request for 'http://some-domain.com/users' would throw an error.

Last Updated on Friday, 30 April 2010 20:46

Web Development