I am trying to add module specific navigation items from within the module. I may be doing this completely wrong. What I have so far is:
config/autoload/navigation.global.php (this works so far)
<?php
return array(
'navigation' => array(
'default' => array(
array(
'label' => 'Home',
'route' => 'home',
'order' => -100,
'pages' => array(
),
),
),
),
);
module/Books/Module.php: (I am trying to add 'Books' navigation items under Home (not inline with))
class Module
{
public function onPreDispatch($e) {
$pages = array(
array(
'label' => 'Books',
'route' => 'books',
),
);
$navigation = $e->getParam('application')->getServiceManager()->get('navigation');
$navigation->findOneByRoute('home')->addPages($pages);
}
/* ... */
}
So in the above example (the route is correct), I do not get an error, the event trigger on pre-dispatch, but nothing gets added to the navigation container.
What I want to accomplish is Navigation as follows:
Home
|-> Books
|-> Module2
|-> etc..