I am a newbie with codeigniter. I am trying to write an application using mysql database. In my site I want to use menu as :
+Homepage
+About
+Services
+Education services
+neurofeedback
+biofeedback
I need some information to understand. I use pages controller as main pages controller:
<?php
class Pages extends CI_Controller {
public function view($page = 'home')
{$this->load->view('templates/header', $data);
$this->load->view('pages/'.$page, $data);
$this->load->view('templates/footer', $data);
my questions are :
1) where the menu controller must be coded inside pages controller or seperate one?
2) how can i make the menu controller from database ?
3) How can i make relation with the menu id and the page id?
I made lots of research but i need a little bit more understanding .
Thank you for your help.
Edit : I have used MY_Controller as you say .
This is my pages controller :
class Home extends MY_Controller {
function __construct() {
parent::__construct();
}
public function view($page = 'home')
{
$this->load->helper('text');
$data['records']= $this->services_model->getAll();
if ( ! file_exists('application/views/pages/'.$page.'.php'))
{
// Whoops, we don't have a page for that!
show_404();
}
$data['title'] = ucfirst($page); // Capitalize the first letter
$this->load->view('pages/'.$page, $data);
}
}