2011-02-09 51 views
0

编辑,由下面的响应修复小问题: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'))); 

所以基本上/管理/分类/复位得到由视图拍摄 - 类别规则,即使我切换顺序。这从来没有成为一个问题。

理想情况下,如果有任何被捕获/管理或/管理,它会忽略:名称/类别规则。是否有可能使管理和/或管理忽略先前的规则并将其路由到其控制器操作,因为在这些区域中没有特定的规则。

老问题:

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

这些规则冲突停靠分页程序上的/类别的名称/分类URL工作。

有没有合并它们?

回答

1

尝试添加“页面”参数的默认值。

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

谢谢(6charlim) – azz0r 2011-02-10 10:14:30