Issues

ZF-11545: Zend_Navigation_Page_Mvc::isActive returns false unless variable route parts match defaults

Issue Type: Bug Created: 2011-07-08T17:46:17.000+0000 Last Updated: 2013-03-13T20:55:21.000+0000 Status: Open Fix version(s): - Next Mini Release ()

Reporter: Mike Dahlke (mdahlke) Assignee: Frank Br├╝ckner (frosch) Tags: - Zend_Navigation

Related issues: - ZF-11443

Attachments:

Description

The fix for issue ZF-11359 broke my application. I have a route which accepts several parameters for sorting a list of items, I want to be able to generate a breadcrumb for this page, but because of the update, the page is only marked as active when using the default sorting parameters.

<pre class="highlight">
resources.router.routes.property_list.route                   = "/admin/property/:sort_col/:sort_ord/:page/:items_per_page"
resources.router.routes.property_list.defaults.controller     = "property"
resources.router.routes.property_list.defaults.action         = "list"
resources.router.routes.property_list.defaults.sort_col       = "address"
resources.router.routes.property_list.defaults.sort_ord       = "asc"
resources.router.routes.property_list.defaults.page           = 1
resources.router.routes.property_list.defaults.items_per_page = 20
resources.router.routes.property_list.reqs.page               = "\d+"
resources.router.routes.property_list.reqs.items_per_page     = "\d+"



<pre class="highlight">
resources.navigation.pages.admin.pages.sections.pages.property.label      = "Properties"
resources.navigation.pages.admin.pages.sections.pages.property.id         = "admin_property"
resources.navigation.pages.admin.pages.sections.pages.property.route      = "property_list"
resources.navigation.pages.admin.pages.sections.pages.property.module     = "default"
resources.navigation.pages.admin.pages.sections.pages.property.controller = "property"
resources.navigation.pages.admin.pages.sections.pages.property.action     = "list"

Defaults compared in old code:

<pre class="highlight">
array (
  'sort_col' => 'address',
  'sort_ord' => 'desc',
  'page' => '1',
  'controller' => 'property',
  'action' => 'list',
  'items_per_page' => '20',
  'module' => 'default',
)



<pre class="highlight">
array (
  'module' => 'default',
  'controller' => 'property',
  'action' => 'list',
)

isActive returns true because only the module, controller, action parts of page defaults are checked against route.

Defaults compared in new code:

<pre class="highlight">
array (
  'sort_col' => 'address',
  'sort_ord' => 'desc',
  'page' => '1',
  'controller' => 'property',
  'action' => 'list',
  'items_per_page' => '20',
  'module' => 'default',
)



<pre class="highlight">
array (
  'controller' => 'property',
  'action' => 'list',
  'sort_col' => 'address',
  'sort_ord' => 'asc',
  'page' => '1',
  'items_per_page' => '20',
  'module' => 'default',
)

isActive return false because route defaults are checked against current request defaults.

Comments

Posted by Mike Dahlke (mdahlke) on 2011-07-14T20:25:57.000+0000

Problem still occurs in 1.11.9.

Posted by Yacine Filali (neutre) on 2011-09-06T17:54:17.000+0000

Problem still occurs in 1.11.10

Ugly workaround for our breadcrumbs is to reset to defaults before displaying the breadcrumbs and restoring their custom values after.

This needs to be bumped up in priority. It's a pretty nasty bug.

Posted by Eloi Poch (eloipoch) on 2012-03-26T15:12:17.000+0000

I'm not very sure but with this it seems work fine:

<pre class="highlight">
if ($this->_route) {
    $route = $front->getRouter()->getRoute($this->_route);
    if (method_exists($route, 'getDefaults')) {
        $myParams = array_merge(
            $route->getDefaults(), $myParams, $reqParams
        );
    }
}

Have you found an issue?

See the Overview section for more details.

Copyright

© 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.

Contacts