Zend 路由相互覆盖
编辑,由以下响应中的修复引起的轻微问题:
现在这些规则发生冲突:
$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')));
所以基本上 /management/category/reset 被视图类别规则捕获,即使我切换那里的顺序。这曾经不是一个问题。
理想情况下,如果有任何内容捕获 /management 或 /administration,它将忽略 :name/category 规则。是否可以使 /management 和 /administration 忽略先前的规则并路由到其控制器操作,因为这些区域中没有其他特定规则。
老问题:
$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')));
这些规则发生冲突,导致分页器无法在 /category-name/category URL 上工作。
有没有办法将它们结合起来?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试为“page”参数添加默认值。
Try add default value for "page" param.