Search code examples
zend-frameworkzend-routezend-paginator

Zend Paginator and Routes


I have read that I would need to setup a route to keep the values in the URL. That's the application.ini example showed in the zendframework reference guide:

routes.example.route = articles/:articleName/:page
routes.example.defaults.controller = articles
routes.example.defaults.action = view
routes.example.defaults.page = 1
routes.example.reqs.articleName = \w+
routes.example.reqs.page = \d+

How could I instantiate the object with the config above and use it in my bootstrap? Example:

  $route = new Zend_Controller_Router_Route(
                    'product/:id',
                    array(
                        'module' => 'default',
                        'controller' => 'product',
                        'action' => 'detail',
                     ),

    );
    $router->addRoute('product', $route);

Solution

  • I figured out, the second array param received by the zend controller router router are the variable requirements.

    $route = new Zend_Controller_Router_Route(
                    'articles/:articleName/:page',
                    array(
                        'module' => 'default',
                        'controller' => 'articles',
                        'action' => 'view',
                        'page' => 1
                     ),
                   array(
                        'articleName' => '\w+',
                        'page' => '\d+'                     
                     )
    
    );
    $router->addRoute('example', $route);