Advertisement
VladimirsBudkins

CI widget

May 22nd, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. public function build_categories($module_name, $table_id) {
  2.         $modules = $this->get_modules();
  3.         //module exist
  4.         if (in_array($module_name, array_keys($modules))) {
  5.             //get current module categories
  6.             $categories = $this->db
  7.                     ->select('c.id,c.p_id,c.status,c.img,ct.title,c.order')
  8.                     ->join('categories_translate ct', "ct.table_id = c.id and ct.lang = '$this->site_lang'", 'left')
  9.                     ->order_by('c.order')
  10.                     ->get_where('categories c', array('c.module_id' => $modules[$module_name]->id))
  11.                     ->result_array();
  12.             if ($categories) {
  13.                 //setup assets
  14.                 $this->assets->add(array(
  15.                     'css' => array(
  16.                         'third_party/icheck/css/all.css'
  17.                     ),
  18.                     'js' => array(
  19.                         'third_party/icheck/icheck.min.js',
  20.                         'js/admin_save_modules_categories.js'
  21.                     )
  22.                 ));
  23.                 //render view with data
  24.                 return $this->load->view(
  25.                                 $this->template->path.DIRECTORY_SEPARATOR.$this->template->componets_path.DIRECTORY_SEPARATOR.'modules_categories',
  26.                                 array(
  27.                                     //build categories tree
  28.                                     'categories' => getTree($categories),
  29.                                     'module_id' => $modules[$module_name]->id,
  30.                                     'table_id' => $table_id,
  31.                                     //get selected categories
  32.                                     'selected' => $this->selected_categories($modules[$module_name]->id, $table_id)
  33.                                 ),
  34.                                 true
  35.                 );
  36.             }
  37.         } else {
  38.             log_message('error', "module {$module_name} not exist");
  39.         }
  40.         return null;
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement