Skip to content
This repository has been archived by the owner on May 24, 2018. It is now read-only.

Latest commit

 

History

History
57 lines (49 loc) · 1.55 KB

zend.navigation.quick-start.rst

File metadata and controls

57 lines (49 loc) · 1.55 KB

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.

<?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',
        ),
    ),
    // ...
);
<!-- in your layout -->
<!-- ... -->

<body>
    <?php echo $this->navigation('navigation')->menu(); ?>
</body>
<!-- ... -->