Where would this class go in the directory structure. I tried placing this in
Controller and Models .. it did not work.. got this erorr. ('Invalid
controller specified (navigation)' )

thanks




mezoni wrote:
> 
> I try experience like this:
> 
> <?php
> 
> class Internal_NavigationController extends Zend_Controller_Action
> {
>     public static $initialized = false;
>     public static $map;
> 
>     public static $action;
>     public static $controller;
>     public static $module;
> 
>     public static $defaultAction;
>     public static $defaultController;
>     public static $defaultModule;
> 
>     public static $front;
>     public static $request;
> 
>     public function init()
>     {
>         if(!self::$initialized) {
>             $config = Zend_Registry::get('config');
>             self::$map = $config->navigation->toArray();
> 
>             self::$front = $this->getFrontController();
>             self::$request = self::$front->getRequest();
> 
>             self::$action     = self::$request->getActionName();
>             self::$controller = self::$request->getControllerName();
>             self::$module     = self::$request->getModuleName();
> 
>             self::$defaultAction     = self::$front->getDefaultAction();
>             self::$defaultController =
> self::$front->getDefaultControllerName();
>             self::$defaultModule     = self::$front->getDefaultModule();
> 
>             self::$initialized = true;
>         }
>     }
> 
>     public function breadcrumbsAction()
>     {
>         $items = array();
> 
>         if(1) {
>         }
> 
>         return $items;
>     }
> 
>     public function menuAction()
>     {
>         $items = array();
> 
>         $modules = $this->getModules();
> 
>         foreach($modules as $key => $module) {
>             $module['url'] = '/';
> 
>             if($key != self::$defaultModule) {
>                 $module['url'] = '/' . $key;
>             }
> 
>             $module['current'] = $key == self::$module;
> 
>             $items[] = $module;
>         }
> 
>         $this->view->items = $items;
>     }
> 
>     public function submenuAction()
>     {
>         $items = array();
> 
>         $moduleName = self::$module;
> 
>         $controllers = $this->getControllers($moduleName);
> 
>         foreach($controllers as $key => $controller) {
> 
>             $url = array();
> 
>             if($moduleName != self::$defaultModule) {
>                 $url[] = $moduleName;
>             }
> 
>             if($key != self::$defaultController) {
>                 $url[] = $key;
>             }
> 
>             $controller['url'] = '/' . implode('/', $url);
>             $controller['current'] = $key == self::$controller;
> 
>             $items[] = $controller;
>         }
> 
>         $this->view->items = $items;
>     }
> 
>     protected function getControllers($module)
>     {
>         $items = array();
>         $attributes  = array('title', 'description');
> 
>         if(!isset(self::$map['modules'][$module]['controllers']) ||
>            !is_array(self::$map['modules'][$module]['controllers'])) {
>             return $items;
>         }
> 
>         foreach(self::$map['modules'][$module]['controllers'] as $key =>
> $controller) {
>             if(!is_array($controller)) {
>                 continue;
>             }
> 
>             $item = $controller;
> 
>             foreach($attributes as $attribute) {
>                 if(!isset($controller[$attribute])) {
>                     $item[$attribute] = $key;
>                 }
>             }
> 
>             $items[$key] = $item;
>         }
> 
>         return $items;
>     }
> 
>     protected function getModule()
>     {
>         $module = false;
>     }
> 
>     protected function getModules()
>     {
>         $items = array();
>         $attributes  = array('title', 'description');
> 
>         if(isset(self::$map['modules']) &&
> is_array(self::$map['modules'])) {
>             foreach(self::$map['modules'] as $key => $module) {
>                 if(!is_array($module)) {
>                     continue;
>                 }
> 
>                 $item = $module;
> 
>                 foreach($attributes as $attribute) {
>                     if(!isset($module[$attribute])) {
>                         $item[$attribute] = $key;
>                     }
>                 }
> 
>                 $items[$key] = $item;
>             }
>         }
> 
>         return $items;
>     }
> }
> 

-- 
View this message in context: 
http://www.nabble.com/Simple-menu-on-every-page-tp16121967p18249961.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to