Croogo Menu Hook

post_id: 68 / post_date: 2011-08-12



The plugin bootstrapper can add a normal menu just like an admin menu.

All you need to do is add a method to app\libs\croogo.php

    public function hookMenu($pluginName) {
        $pluginName = Inflector::underscore($pluginName);
        Configure::write('Normal.menus.main.'.$pluginName, 1);
    }

Then in app\views\helpers\layout.php, you simply add

//at the end of menu()
        $themeMenu = Configure::read('Normal.menus.' . $menuAlias);
        if ($themeMenu) $output .= $this->_themeMenu($themeMenu);
//then
    function _themeMenu($themeMenu)
    {
      $op = '<ul class="sf-menu">';
      foreach (array_keys($themeMenu) AS $p)
        $op .= '<li>' . $this->View->element('normal_menu', array('plugin' => $p)) . '</li>';
      $op .= '</ul>';
      return $op;
    }