public function get_index($lang = LANG) { //LOAD JS LIBS Asset::container('footer')->add('menu', 'bundles/cms/js/sections/menus_list.js', 'cms'); $this->layout->header_data = array('title' => LL('cms::title.menus', CMSLANG)); $this->layout->top_data = array('search' => false); //GET DATA $data = CmsMenu::with('pages')->where_lang($lang)->order_by('name', 'asc')->get(); $this->layout->content = View::make('cms::interface.pages.menu_list')->with('data', $data)->with('lang', $lang); }
/** * MENU Marker - Show a menu saved in Service / Menu * * [$MENU[{ * "name":"<menu name>", * "class":"<class>", => OPTIONAL (<ul> class) * "tpl":"<tpl_name>" => OPTIONAL (in /partials/markers) * }]] * * @param array * @return string */ public static function MENU($vars = array()) { //Get variables from array $vars if (!empty($vars)) { extract($vars); } //Bind variables $_name = ''; if (isset($name) and !empty($name)) { $_name = $name; } $_class = 'menu'; if (isset($class) and !empty($class)) { $_class = $class; } $_tpl = 'menu'; if (isset($tpl) and !empty($tpl)) { $_tpl = $tpl; } //Get DB information if (!empty($_name)) { //CACHE DATA if (CACHE) { $m = Cache::remember('menu_' . $_name . '_' . SITE_LANG, function () use($_name) { return CmsMenu::where_name($_name)->where_lang(SITE_LANG)->first(); }, 5); } else { $m = CmsMenu::where_name($_name)->where_lang(SITE_LANG)->first(); } if (!empty($m)) { $id = $m->id; $nested = (bool) $m->is_nested; $lower_parent = 0; if ($nested) { $lower_parent = $m->parent_start; } //CACHE DATA if (CACHE) { $menu = Cache::remember('menu_pages_' . $_name . '_' . SITE_LANG, function () use($_name, $nested, $lower_parent) { return CmsMenu::with(array('pages' => function ($query) use($nested, $lower_parent) { if ($nested) { $query->where('parent_id', '=', $lower_parent); } }))->where_name($_name)->where_lang(SITE_LANG)->first(); }, 5); } else { $menu = CmsMenu::with(array('pages' => function ($query) use($nested, $lower_parent) { if ($nested) { $query->where('parent_id', '=', $lower_parent); } }))->where_name($_name)->where_lang(SITE_LANG)->first(); } //Load file lable and title if (!empty($menu->pages)) { $pages = $menu->pages; $nested = (bool) $nested; } else { $pages = array(); $nested = false; } } else { $id = null; $pages = array(); $nested = false; } } else { $id = null; $pages = array(); $nested = false; } $options = array('id' => $_name, 'class' => $_class); $view = LOAD_VIEW($_tpl); $view['mid'] = $id; $view['pages'] = $pages; $view['nested'] = $nested; $view['options'] = HTML::attributes($options); return $view; }