Zend 路由相互覆盖

发布于 2024-10-16 23:02:33 字数 1202 浏览 4 评论 0原文

编辑,由以下响应中的修复引起的轻微问题:

现在这些规则发生冲突:

    $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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

朮生 2024-10-23 23:02:33

尝试为“page”参数添加默认值。

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

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)
    )
 ); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文