Last Updated: February 25, 2016
· joelstahre

Navigation in Zend Framework 1

A simple example of Navigation in zend framework 1

Create a xml file in application/configs/

ex. application/configs/navigation.xml

<?xml version="1.0" encoding="UTF-8"?>





Add this to application/Bootstrap.php

protected function _initNavigation()
        $layout = $this->getResource('layout');
        $view = $layout->getView();

        $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'nav');

        $navigation = new Zend_Navigation( $config );
        $view->navigation( $navigation );

Add this to a view script or a layout script, ex. application/layouts/myLayout.phtml

<nav class="myNav">

    <?php echo $this->navigation()->menu(); ?>


// ->setUlClass('nav'); sets a custom CSS class for the navigation
<?php echo $this->navigation()->menu()->setUlClass('nav'); ?>