Commits

David Lukas committed c71333b

Navigation view helper - wip

Comments (0)

Files changed (4)

      */
     protected $renderer;
 
+    /**
+     * Navbar container
+     * @var \Zend\Navigation\Navigation
+     */
+    protected $navbarContainer;
+
     /* ********************** METHODS ************************** */
 
     public function init(Manager $moduleManager) {
         $locator  = $app->getLocator();
 
         //Store renderer as a property, it will be used by the onRoute() method
-        $this->renderer = $locator->get('Zend\View\Renderer\PhpRenderer');
+        $this->renderer         = $locator->get('Zend\View\Renderer\PhpRenderer');
+        $this->navbarContainer  = $locator->get('dlutwb-nav-menu-main');
 
         //Register DluTwBootstrap view navigation helpers
         $this->renderer->plugin('navigation')
     public function onRoute(\Zend\Mvc\MvcEvent $e) {
         $routeMatch      = $e->getRouteMatch();
         $this->renderer->plugin('url')->setRouteMatch($routeMatch);
+        $ri = new \RecursiveIteratorIterator($this->navbarContainer, \RecursiveIteratorIterator::SELF_FIRST);
+        foreach ($ri as $page) {
+            if($page instanceof \Zend\Navigation\Page\Mvc) {
+                $page->setRouteMatch($routeMatch);
+            }
+        }
     }
 }

config/module.config.php

                         array(
                             'label'     => 'Demo',
                             'title'     => 'DluTwBootstrap Demo',
-                            'uri'       => '#',
+                            'type'       => 'uri',
                             'pages'     => array(
                                 array(
                                     'label'         => 'Forms',

tests/bootstrap.php

+<?php
+//Ini settings
+ini_set('display_startup_errors', true);
+ini_set('display_errors', true);
+
+//ZF2 Autoloader
+chdir(dirname(__DIR__));
+require_once ('c:/WebDev/Libraries/ZF2/v2.0.0beta3-145-gffc97f8/library/Zend/Loader/AutoloaderFactory.php');
+Zend\Loader\AutoloaderFactory::factory();

view/tw-bootstrap-demo/navigation.phtml

 <?php
 //echo $this->navigation()->menu($navMenuMain);
 echo $this->navigation()->twbNavbar($navMenuMain);
+echo $this->navigation()->menu($navMenuMain);
 ?>
 
 <h2>Navigation</h2>