ZF-6823: Zend_Navigation not compatable with wildcard routes

Description

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

Comments

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.

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 ); }

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.

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;
    }

{/quote}

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}

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

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

Look at Revision 24119