Zend Framework Navigation – Creating Menus in Zend Framework

zend-framework-navigation

Zend Framework Navigation – Creating Menus in Zend Framework

Recently I made my mind to get back to my first love – Programming. So after an year of hard work, setting up my new born company, streamlining processes and people and getting things into flow, finally I have gotten time enough to focus on my love.

So I shall be writing a series of posts on Zend Framework while I code these projects.

This post is about creating menus using Zend Navigation.

Here is the step my step process.

1. In the application\configs folder create a file called as navigation.xml
You can download the zipped version from below.
navigation.xml

2. Add these lines of code to the Bootstrap.php file.

protected function _initNavigation(){
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$config = new Zend_Config_Xml(APPLICATION_PATH .'/configs/navigation.xml','nav');
$container = new Zend_Navigation($config);
$view->navigation($container);

3. Add this code in your layout.phtml file.


?>

Thats it!

You should see a menu like this now.

Post your comments, if you have any doubts.