I made a navigation in Zend Framework 2 using a global file located in config/autoload
. how can I get in this global file the route parameters?
I have tried this:
$helper = new Zend\View\Helper\ServerUrl();
$active_url = $helper->getHost();
but this returns the whole url. For exemle I have an url like this
www.mysite.com/controller/action/id/3
I need to know the id.
My global file return a navigation array that looks like this:
return array(
'navigation' => array(
'default' => array(
array(
'label' => 'Home',
'route' => 'admin',
'active' => true,
'resource' => 'Admin\Controller\Index',
'privilege' => 'index',
'pages' => array(
'label' => 'My posts ',
'route' => 'admin/default',
'params' => array(
'controller' => 'posts',
'action' => 'edit'
),
'resource' => 'Admin\Controller\Posts',
'privilege' => 'edit',
),
)
)
)
);
It all work fine as long as the route doesn't contain parameters. If my url contain an ID parameters my menu link and the breadcrumbs are form just with the controller and action without ID and in the same.
So, instead of:
www.mysite.com/posts/edit/id/12
My link looks like:
www.mysite.com/posts/edit