/** * Edit single menu * * @param int $id */ public function edit($id) { // If post is send if ($this->input->post()) { $result = $this->menu->from_form(NULL, NULL, array('id' => $id))->update(); if ($result) { // Set informations $this->session->set_flashdata('success', lang('alert.success.saved_changes')); // Redirect redirect(admin_url('menu/edit/' . $id)); } } $menu = $this->menu->get($id); if (!$menu) { show_404(); } $this->load->module('menu/admin/admin_menu_items'); // Load menu_items controller $locale = $this->input->get('locale') ? $this->input->get('locale') : config_item('selected_locale'); // Get pages list $pages = $this->page_translations->where('locale', $locale)->get_all(); // Set view data $this->data['menu'] = $menu; $this->data['subnav_active'] = 'edit'; $this->data['return_link'] = $this->getReturnLink($this->sessionName); $this->data['selected_language'] = $this->config->item($locale, 'system_languages_by_locale')->name; $this->data['locale'] = $locale; $this->data['menu_items_controller'] = $this->admin_menu_items; $this->data['pages_options'] = obj_to_options_array($pages, 'id', 'title'); // Load the view $this->render('menu/edit', $this->data); }
/** * Menu items list - by menu_id * * @param int $menu_id * @return string */ public function lists($menu_id, $localeCode = '') { $locale = $localeCode != '' ? $localeCode : config_item('selected_locale'); $menu_items = $this->menu_items->where(['menu_id' => $menu_id, 'locale' => $locale])->order_by('sort')->get_all(); $menu_items_parents = $this->menu_items->prepare_parent_array($menu_items); // Get pages list $pages = $this->page_translations->where('locale', $locale)->get_all(); // Set view data $data['menu_items'] = generate_menu_tree($menu_items_parents, 0, [], 100, 0, ['pages' => obj_to_options_array($pages, 'id', 'title')]); if ($this->input->is_ajax_request()) { $this->render('menu/items/index', $data); } else { return $this->render('menu/items/index', $data, true); } }