Search code examples
zend-frameworkzend-navigation

Zend Naviation Menu View Helper - All links are the same?


heres my setup:

http://www.example.com/<module>/<controller>/<action>

I have this route defined:

$router->addRoute(
            'editUser', new Zend_Controller_Router_Route('admin/users/edit/:id',
                array(
                    'module'     => 'admin',
                    'controller' => 'users',
                    'action'     => 'edit',
                    'route'      => 'default',
                    'id'         => 0,
                ),
                array('id' => '\d+')
            )
        );

So my sites navigation menu works fine until i go to a page like so:

http://www.example.com/admin/users/edit/10

It displays the page no problem but now every link in the navigation menu points to http://www.example.com/admin/users/edit

Not sure why this is happening and would like to get it fixed while maintaining use of the router.

Thanks in advance for any pointers!


Solution

  • It's a common problem.

    If you are using custom routes in your navigation (editUser in your case) you must explicitly pass 'default' route to Zend_Navigation pages and url() view helpers.