i do have a problem regarding rendering the navigation in zf2. I have not found anybody else having this issue. But maybe you have a clue.
Althought everything seems to be configured right, due to the fact that everything does work, rendering zend navigation does not mark the active route with class="active".
This is part of my module.config.php:
'service_manager' => array(
'factories' => array(
'app_navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
'User\Acl\Service' => 'User\Acl\ServiceFactory',
'User\Auth\Service' => 'User\Authentication\ServiceFactory',
),
),
//global config key for all navigation configurations
'navigation' => array(
//name of the DefaultNavigation created by DefaultNavigationFactory
'default' => array(
//config of first page
'welcome' => array(
'label' => 'Home',
'route' => 'welcome',
'controller' => 'People\Controller\PeopleController',
'action' => 'welcome',
'type' => 'uri',
'uri' => '/welcome',
'module' => 'TheGlobalDatabase',
),
...
This is the route:
'router' => array(
'routes' => array(
'welcome' => array(
'type' => 'segment',
'options' => array(
'route' => '/welcome',
'defaults' => array(
'controller' => 'People\Controller\People',
'action' => 'welcome',
),
),
),
I do echo the navigation in the layout like this:
echo $this->navigation()->menu()->renderMenu('app_navigation',array('ulClass'=>'nav navbar-nav welcome'));
Maybe you have a hint, what else to check.
Thank you all!
You have missing or incorrect config in both route and navigation.
Navigation
You will never need to use the
typeparam when using array config. It is the navigation factory's job to determine if the type is eitheruriormvc. Just remove the config for it.The navigation
controllerShould be the registered service name of the controller, not the fully qualified class name.'controller' => 'People\Controller\People'.Also You do not need to specify the
controllerandactionin the navigation config when using a route param.With these changes, the navigation is very simple.
Route
It could be a
Literalroute (as there are no parameters being passed in) and you are missing themay_terminateargument which will be required if you wish to match on your route.