I am following the tuts+ course for developing CMS for news portal. I am getting instance using codeigniter super object.I have already included url helper in autoload then also i can not fetch the slug for the page. I am checking uri with the slug name of the item so that i can find the active page.
$CI =& get_instance();//for getting instance
$slug_name=$CI->uri->segment(1);
Here $CI will get all the instances but the $active will have NULL value $active=$CI->uri->segment(1)==$item['slug']?TRUE:FALSE;
please help Thanks in advance
Maybe you are not checking for true in $active. I've put your function from comment. Let me know, if it is working now.
function get_menu($array, $child=false) {
$CI = &get_instance();
$str = '';
if (count($array) > 0) {
foreach ($array as $item) {
$active = $CI->uri->segment(1) == $item['slug'] ? TRUE : FALSE;
if (isset($item['children']) && count($item['children']) > 0) {
$str .= $active == TRUE ? '<li class="dropdown active">' : '<li class="dropdown">'; //list code here
} else {
$str .= $active == TRUE ? '<li class="active">' : '<li>';
}
}
}
return $str;
}