开发者

Zend Framework: Routing seems to interfere with rendering of Zend_Navigation menu

i have setup a route like below in bootstrap.php

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

when i try to goto /users/1, and in view script do echo $page->getHref(), i开发者_Python百科 get

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

when i try to goto /users/view/id/1 it works ok. i am wondering why would rendering menu items from Zend_Navigation crash in something separate like routing?


ok i solved the problem with help from another post

basically, i need to add a default value for id

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜