lo que busco como recorrer mi json para luego utizalarlo en el menu , una ves que lo haya recorrido mi array bien , en la parte dee home llamo la vista como <?php $this->load->view('menu/menu'); ?>
solo que al visualizarlo en http://localhost/storeLTE/home me dice que no esta declara la variable y asi mi pregunta como puediera pasar todo para recorrerlo y al momento de pasarlo al home que igual se vea bien?
login controller
public function getModules(){
if($this->session->userdata('log')){
$data = $this->session->userdata('log');
$menu = array();
$seccions = $this->module->get_rows();
foreach ($seccions as $index => $seccion){
$modules = $this->module->query("SELECT CONCAT('".$seccion['id']."',storelte_modulo.id) AS id,CONCAT('".base_url('assets/img/sidebar')."','/',storelte_modulo.icon) as icon, 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->json($menu);
$this->load->view('menu/menu',$menu);
}
}
menu view
<aside class="main-sidebar">
<section class="sidebar">
<ul class="sidebar-menu">
<li class="treeview">
<?php foreach ($variable as $key => $value): ?>
<?php endforeach ?>
</li>
</ul>
</section>
</aside>
home view
<!-- Left side column. contains the logo and sidebar -->
<?php $this->load->view('menu/menu'); ?>
json
[
{
"id":"1",
"seccion":"Inventario",
"data":[
{
"id":"11",
"icon":"http:\/\/localhost\/storeLTE\/assets\/img\/sidebar\/items.png",
"value":"Productos",
"seccion_id":"1",
"url":"http:\/\/localhost\/storeLTE\/inventory\/product"
}]
},
{
"id":"2",
"seccion":"Compras",
"data":[
{
"id":"22",
"icon":"http:\/\/localhost\/storeLTE\/assets\/img\/sidebar\/suppliers.png",
"value":"Compras",
"seccion_id":"2",
"url":"http:\/\/localhost\/storeLTE\/purchase\/purchase"
}]
},
{
"id":"3",
"seccion":"Ventas",
"data":[
{
"id":"33",
"icon":"http:\/\/localhost\/storeLTE\/assets\/img\/sidebar\/sales.png",
"value":"Ventas",
"seccion_id":"3",
"url":"http:\/\/localhost\/storeLTE\/sale\/sales"
}]
},
{
"id":"4",
"seccion":"Reportes",
"data":[
{
"id":"44",
"icon":"http:\/\/localhost\/storeLTE\/assets\/img\/sidebar\/employees.png",
"value":"Provedores",
"seccion_id":"4",
"url":"http:\/\/localhost\/storeLTE\/provider\/provider"
}]
}]