ZF-6823: Zend_Navigation not compatable with wildcard routes

Issue Type: Bug Created: 2009-05-27T05:32:12.000+0000 Last Updated: 2013-03-13T20:55:23.000+0000 Status: Open Fix version(s): - Next Mini Release ()

Reporter: Josh Ribakoff (jshpro2) Assignee: Frank Br├╝ckner (frosch) Tags: - Zend_Navigation

Related issues: - ZF-11545

Attachments: - Mvc.php


Zend navigation is not compatible with wild card based routes. If a route has variable params ( ie contains "*" ), then in order to specify the module on the mvc_page object it passes the module as a user parameter in that route, defeating the purpose of routes.

It would be better to open up some observation points from the route class so the page class could decide not when to pass a redundant /module/foo/controller/bar in the URL when the user has specified custom routes with wildcards in them


Posted by Robin Skoglund (robinsk) on 2009-05-27T05:49:55.000+0000

Yes, pages introspecting route(r)s would be great.

The routing subsystem needs to be partially rewritten, and requires changes that break backwards compatibility. This is scheduled for ZF 2.0, and at the same time, Zend_Navigation_Page_Mvc will be refactored to reflect changes in route(r)s.

Posted by Josh Ribakoff (jshpro2) on 2009-05-27T05:58:36.000+0000

Another improvement would be making it easier for users to get their dynamic content into the breadcrumbs view helper. Something like an action helper that does something like:

protected function setBreadcrumbOptions( $id, $options ) { $menu = Ne8::getInstance()->getMenu()->findBy( 'id', $id ); // would probably check the registry or allow menu to be injected by paramater $menu->setOptions( $options ); }

Posted by Robin Skoglund (robinsk) on 2009-05-27T06:04:02.000+0000

The breadcrumbs thing sounds interesting. I would appreciate it if you could create a separate issue (improvement) for this, and elaborate on some of your thoughts.

Posted by John Boehr (jboehr) on 2009-10-12T15:57:43.000+0000

This is not fully tested, however this seems to fix the problem for the moment, in my use cases. It simply removes any specified params that match the default params set in the route.

Zend/Navigation/Page/Mvc.php (from Zend 1.9.2) : 202

after: {quote} $params = $this->getParams();

    if ($param = $this->getModule()) {
        $params['module'] = $param;

    if ($param = $this->getController()) {
        $params['controller'] = $param;

    if ($param = $this->getAction()) {
        $params['action'] = $param;


add: {quote} $router = self::$_urlHelper->getFrontController()->getRouter(); $routeName = $this->getRoute(); if( $router->hasRoute($routeName) ) { $route = $router->getRoute($routeName); if( method_exists($route, 'getDefaults') ) { $defaults = $route->getDefaults(); foreach( $params as $key => $value ) { if( isset($defaults[$key]) && $defaults[$key] == $value ) { unset($params[$key]); } } } } {/quote}

Posted by John Boehr (jboehr) on 2009-10-12T15:59:20.000+0000

Ok sorry, looks like JIRA fubar'ed my post, here is the current modified file (as of 1.9.2).

Posted by Kai Uwe (kaiuwe) on 2011-06-09T08:22:47.000+0000

The issue is similar to ZF-11359, but we have to change the method "getHref".

Look at Revision 24119

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.