Quick StartΒΆ
The fastest way to get up and running with Zend\Navigation is by the navigation key in your service manager configuration and the navigation factory will handle the rest for you. After setting up the configuration simply use the key name with the Zend\Navigation view helper to output the container.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | <?php
// your configuration file, e.g., config/autoload/global.php
return array(
// ...
'navigation' => array(
'default' => array(
array(
'label' => 'Home',
'route' => 'home',
),
array(
'label' => 'Page #1',
'route' => 'page-1',
'pages' => array(
array(
'label' => 'Child #1',
'route' => 'page-1-child',
),
),
),
array(
'label' => 'Page #2',
'route' => 'page-2',
),
),
),
'service_manager' => array(
'factories' => array(
'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
),
),
// ...
);
|
1 2 3 4 5 6 7 | <!-- in your layout -->
<!-- ... -->
<body>
<?php echo $this->navigation('navigation')->menu(); ?>
</body>
<!-- ... -->
|