мой контроллер
[code]$data['navlist'] = $this->MCats->getCategoriesNav();[/code]
модель
[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;
}
[/code]
и просмотров
[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";
}[/code]
я не получаю название категории для верхнего меню, пожалуйста, помогите мне в этом,