Zend\Navigation\Page\Mvc::getHref does not use RouteMatch parameters #4095
Zend\Navigation\Page\Mvc::getHref does not use RouteMatch parameters #4095
Conversation
…when they are available
…utematch-parameters Zend\Navigation\Page\Mvc::getHref does not use RouteMatch parameters
@adamlundrigan //module.config.php:
'router' => array(
'routes' => array(
'album' => array(
'type' => 'segment',
'options' => array(
'route' => '/album[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Album\Controller\Album',
'action' => 'index',
),
),
),
),
),
//navigation:
'navigation' => array(
'default' => array(
array(
'label' => 'Home',
'route' => 'home',
),
array(
'label' => 'Album',
'route' => 'album',
'pages' => array(
array(
'label' => 'Add',
'route' => 'album',
'action' => 'add',
),
array(
'label' => 'Edit',
'route' => 'album',
'action' => 'edit',
),
array(
'label' => 'Delete',
'route' => 'album',
'action' => 'delete',
),
),
),
),
),
//in view script:
<?php echo $this->navigation('navigation')->menu(); ?> In normal: Sorry for my English! |
@weierophinney : this PR introduce a big issue in navigation handling. Navigation URLs must not pull params from active page, otherwise every navigation page with undefined params takes current page params, that is definitively wrong. However @adamlundrigan is likely also right: current page breadcrumb has to have current page params. I suggest to:
This way involves some test deletion and some new code in A big note: at the time of writing, _release 2.1.5 |
…n/feature/navigation-mvc-routematch-parameters Zend\Navigation\Page\Mvc::getHref does not use RouteMatch parameters
The MVC page type in Navigation does not pull matched parameters from the provided RouteMatch object, which results in an error when using the breadcrumbs view helper:
My route hierarchy:
The simplest fix i've found is to change
Zend\Navigation\Page\Mvc::getHref
to use the parameters from the RouteMatch object (if they are set) as the defaults and then merge the parameters set directly on theZend\Navigation\Page\Mvc
into that:Though I am not 100% certain this is a comprehensive fix, or that it doesn't break / cause unexpected results with the other navigation view helpers (my application only uses bredcrumbs currently)