Welcome Guest, Not a member yet? Register   Sign In
having small problem wth this ci navigation script
#1

[eluser]dhaulagiri[/eluser]
my controller is

Code:
$data['navlist'] = $this->MCats->getCategoriesNav();

model is

Code:
function getCategoriesNav(){
        $data = array();
        $this->db->group_by('parentid', 'id');
        $Q = $this->db->get('categories');
        if($Q->num_rows >0){
            foreach($Q->result() as $row){
                if($row->parentid > 0){
                    $data[0][$row->parentid]['children'][$row->id] = $row->name;
                }else{
                $data[0][$row->id]['name'] = $row->name;
                }
            }
        }
        $Q->free_result();
        return $data;
    }

and views is


Code:
if(count($navlist)){
    echo "<ul>";
    foreach($navlist as $key => $list){
        foreach($list as $topkey => $toplist){
            echo "<li class='cat'>";
            echo anchor("welcome/cat/$topkey", $toplist);
            echo "</li>\n";
            if(count($toplist['children'])){
            foreach($toplist['children'] as $subkey => $subname){
                echo "\n<li class='subcat'>";
                echo anchor("welcome/cat/$subkey", $subname);
                echo "</li>";
                }
            }
        }
        
    }
    echo "</ul>\n";
    
}

i am not getting category name for top menu, please help me on this,




Theme © iAndrew 2016 - Forum software by © MyBB