ZF-8438: Route params patch for Zend_Navigation_Page_Mvc

Issue Type: Patch Created: 2009-12-02T00:19:39.000+0000 Last Updated: 2011-06-06T09:24:09.000+0000 Status: Closed Fix version(s): - 1.11.8 (07/Jul/11)

Reporter: Marko Korhonen (back-2-95) Assignee: Kai Uwe (kaiuwe) Tags: - Zend_Navigation

Related issues: - ZF-8830



When I make my root navigation, it makes my links filled with all params as module, controller action.


route: profile/* > should render link Profile

but instead it renders: Profile

I made following additions and changes to. Zend/Navigation/Page/Mvc.php

I added variable:

<pre class="highlight">
public static $router = null;

And the get method for router:

<pre class="highlight">
public static function getRouter()
  if (null === self::$router) {
    self::$router = Zend_Controller_Front::getInstance()->getRouter();

  return self::$router;

Then I added some route checking to end of method getHref():

<pre class="highlight">
$router = self::getRouter();
if ($router->hasRoute($this->getRoute()))
  $route = $router->getRoute($this->getRoute());
  // gets route defaults and compares it to given params, then
  // returns only the ones are not found from route defaults        
  $params = array_diff($params, $route->getDefaults());
$url = self::$_urlHelper->url($params,$this->getRoute(),$this->getResetParams());

return $this->_hrefCache = $url;

br, Marko


Posted by Kai Uwe (kaiuwe) on 2011-02-15T00:16:19.000+0000

Added code tags

Have you found an issue?

See the Overview section for more details.


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

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