开发者

Zend Route Overwriting each other

开发者 https://www.devze.com 2023-02-09 07:08 出处:网络
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\' =&

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')));

The开发者_运维知识库se rules clash which stops paginator working on the /category-name/category URL.

Is there away to combine them?


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)
    )
 ); 
0

精彩评论

暂无评论...
验证码 换一张
取 消