Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @author S.Serdyuk
- * @copyright (c) 2013, WebAkula
- *
- */
- class App_View_Helper_SiteMenu extends Zend_View_Helper_Abstract {
- protected $_viewScriptExt = 'phtml';
- protected $_path;
- protected $_view;
- public function siteMenu() {
- $this->_path = MENU_VIEWSCRIPT_PATH;
- $this->_view = new Zend_View;
- return $this;
- }
- public function __get($name) {
- $container = $this->getContainer($name);
- $this->_view->navigation()->setContainer($container);
- return $this->_view->navigation()->menu($container)->renderMenu();
- }
- public function getContainer($name) {
- $model = new Menu_Model_Table;
- $menu = $model->get($name);
- /* $file = $name . '.' . $this->_viewScriptExt;
- $path = $this->_path . $file;
- if (!file_exists($path)) {
- throw new Exception("Viewscript file '$file' not found in the following path(s): '$this->_path'");
- } */
- //var_dump($menu);
- //return;
- $langId = null;
- if(APP_MULTILINGUAL) {
- $langs = new Core_Model_Languages();
- $langId = $langs->getLanguageId(Zend_Registry::get('LANGUAGE'));
- }
- $items = new Menu_Model_Items;
- $list = $items->getMenu($menu['id'], $langId);
- $entries = array();
- foreach ($list as $row) {
- $entry['id'] = $row['id'];
- $entry['parent_id'] = $row['parent_id'];
- $entry['title'] = $row['title'];
- $entry['label'] = $row['title'];
- $entry['external_url'] = $row['link'];
- $entry['uri'] = $row['link'];
- $entry['class'] = 'nav-item';
- // $entry['active'] = true;
- $entries[] = $entry;
- }
- $entries = Core_Helper_Tree::build($entries);
- $container = new Zend_Navigation();
- $container->setPages($entries);
- return $container;
- }
- public function breadcrumbs($name) {
- return $this->_view->navigation()->breadcrumbs($this->getContainer($name));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement