title: how can I do a menu list with permission on codeigniter?
body: <p>I want to display a menu list with the respetives modules that has permission. I have my model,and controller for it, but I dont know how to pass it to my home view and display it. either for php directly or ajax.</p>
  
  <p>controller</p>
  
  <pre><code> &lt;?php
  defined('BASEPATH') OR exit('No direct script access allowed');
  
  class Login extends MY_Controller {
      public function __construct(){
          parent::__construct();
      }
  
      public function index(){
          $data['module'] = 'Login';
          $this-&gt;load-&gt;view('login',$data);
      }
  
      public function getAccess(){
          if ($this-&gt;session-&gt;userdata('logged_in') == TRUE){
              redirect('home');
          }else{
              $username = $this-&gt;security-&gt;xss_clean($this-&gt;input-&gt;post('username'));
              $password = $this-&gt;security-&gt;xss_clean($this-&gt;input-&gt;post('password'));
              $array = $this-&gt;user-&gt;login($username,$password);
              if ($array[0] == 0) {
                  echo 0;
              }else{
                  $data_session = array(
                      'id' =&gt; $array[0]['id'],
                      'name' =&gt; $array[0]['nombre'],
                      'last_name' =&gt; $array[0]['apellido'],
                      'type' =&gt; $array[0]['id_perfil'],
                      'logged_in' =&gt; TRUE 
                  );
                  $this-&gt;session-&gt;set_userdata('log',$data_session);
              }
          }
      } 
  
      public function logout(){
          $this-&gt;session-&gt;sess_destroy();
          redirect('login');
      }
  
      public function getModules($module_id){
          if ($this-&gt;session-&gt;userdata('log')){
              $data = $this-&gt;session-&gt;userdata('log');
              $menu = array();
              $seccions = $this-&gt;module-&gt;get_rows();
              foreach ($seccions as $index =&gt; $seccion) {
                  //echo json_encode($seccion);
                  $modules = $this-&gt;module-&gt;query("SELECT concat('".$seccion['id']."',storelte_modulo.id) AS id, storelte_modulo.modulo AS VALUE,storelte_modulo.seccion_id,concat('".base_url()."',storelte_modulo.url) as url FROM storelte_modulo INNER JOIN storelte_modulo_perfil ON  storelte_modulo_perfil.modulo_id = storelte_modulo.id WHERE seccion_id = $seccion[id] AND storelte_modulo_perfil.perfiles_id =  $data[id] AND storelte_modulo_perfil.status = 1");
                  $seccions[$index]['data']= $modules;
                  if(!count($seccions[$index]['data']))
                      unset($seccions[$index]);
              }
              foreach($seccions as $item)
                  array_push($menu,$item);
              $this-&gt;json($menu);
          }
      }
  }
  </code></pre>
  
  <p>module_model</p>
  
  <pre><code>class Module extends CI_Model {
      public function __construct(){
          parent::__construct();
  
      }
  
      public function get_rows(){
          $this-&gt;db-&gt;select('id,seccion');
          $this-&gt;db-&gt;from('storelte_seccion');
          return $this-&gt;db-&gt;get()-&gt;result_array();
      }
  
      public function query($query){
          return $this-&gt;db-&gt;query($query)-&gt;result_array();
      }
  
  }
  </code></pre>
  
  <p>html where will be displayed the modules with permissions</p>
  
  <pre><code>&lt;div class="row"&gt;
                &lt;h3 class="text-center"&gt;Welcome to storeLTE, click a module below to get started!&lt;/h3&gt;
                &lt;div class="home_module_list"&gt;
  
                &lt;/div&gt;
            &lt;/div&gt;
  </code></pre>