I have issue displaying menu on the website. The link website.com/menu displaying links from the database.
But on the menubar of the website it is not showing.
Controller Menu:
public function index()
{
$this->load->model("menu_model");
$data = array();
if ($menu_query = $this -> menu_model-> getCategories()) {
$data['recordsmenu'] = $menu_query;
}
$this->load->view("includes/menu", $data);
}
Menu_model:
public function getCategories()
{
$this->db->select('*');
$this->db->from('category_name');
$this->db->where('parent_id','0');
$this->db->order_by('category_id', 'asc');
$menu_query = $this->db->get();
if ($menu_query->num_rows() != 0) {
return $menu_query->result();
} else {
return false;
}
}
Menu View:
<ul class="nav navbar-nav">
<?php if(isset($recordsmenu)) : foreach ($recordsmenu as $menu): ?>
<li><a href="<?php echo base_url(); echo $menu->linkname;?>"><?php echo $menu->catname;?></a></li>
<?php endforeach; ?>
<?php else : ?>
<?php endif; ?>
</ul>
While the Controller of all other pages of website is as:
function index()
{
$this->load->model('slides_model');
if ($query = $this -> slides_model-> get_records()) {
$data['records'] = $query;
}
$data['main_content'] = 'home';
$this ->load->view('includes/template', $data);
}
The template.php file in includes folder is:
<?php $this->load->view('includes/header'); ?>
<?php $this->load->view('includes/menu'); ?>
<?php $this->load->view($main_content); ?>
<?php $this->load->view('includes/footer'); ?>