Search code examples
zend-frameworkzend-paginator

Zend Route Overwriting each other


Edit, Slight problem caused by the fix in the respond below:

Now these rules clash:

    $router->addRoute('view-category',      new Zend_Controller_Router_Route(':id/category/:page',  array('module' => 'default', 'controller' => 'category', 'action' => 'view', 'page' => null)));

    $router->addRoute('management/category',    new Zend_Controller_Router_Route('management/category/',    array('module' => 'management', 'controller' => 'category', 'action' => 'index')));

So basically /management/category/reset gets captured by the view-category rule, even if I switch there order. This never used to be an issue.

Ideally if anything caught /management or /administration it would ignore the :name/category rule. Is it possible to make /management and /administration ignore previous rules and route to its controller action as there are no specific rules otherwise in those areas.

OLD QUESTION:

$router->addRoute('view-category',      new Zend_Controller_Router_Route(':id/category',    array('module' => 'default', 'controller' => 'category', 'action' => 'view')));
$router->addRoute('view-category-page', new Zend_Controller_Router_Route(':id/category/:page',  array('module' => 'default', 'controller' => 'category', 'action' => 'view')));

These rules clash which stops paginator working on the /category-name/category URL.

Is there away to combine them?


Solution

  • Try add default value for "page" param.

    $router->addRoute('view-category', 
        new Zend_Controller_Router_Route(':id/category/:page',  
            array('module' => 'default', 
                  'controller' => 'category', 
                  'action' => 'view',
                  'page' => null)
        )
     );