2010-08-04 22 views
0

的渲染干擾我已經安裝在bootstrap.phpZend框架:路由似乎與Zend_Navigation菜單

$route = new Zend_Controller_Router_Route(
    'users/:id', 
    array(
     'controller' => 'users', 
     'action' => 'view' 
    ) 
); 
$router->addRoute('viewUser', $route); 

當我嘗試轉到/users/1,鑑於腳本做echo $page->getHref()像下面的路線,我得到

Fatal error: Zend_Controller_Router_Exception: id is not specified in D:\ResourceLibrary\Frameworks\ZendFramework\library\Zend\View\Helper\Navigation\HelperAbstract.php on line 522

當我嘗試轉到/users/view/id/1它工作正常。我想知道爲什麼從Zend_Navigation呈現菜單項崩潰在像路由單獨的東西?

回答

1

好吧,我解決了幫助,這個問題從another post

基本上,我需要爲ID添加一個默認值

$route = new Zend_Controller_Router_Route(
    'users/:id', 
    array(
     'controller' => 'users', 
     'action' => 'view', 
     'id' => '0' 
    ) 
); 
$router->addRoute('viewUser', $route); 
+0

OPS但現在我還有一個問題。我不能去'/用戶'因爲它會自動路由到'/用戶/ 0' – 2010-08-06 07:07:30