views:

29

answers:

1

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 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?

A: 

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);
jiewmeng
ops but now i have another problem. i cant go to '/users' cos it will automatically route to '/users/0'
jiewmeng