Welcome Guest, Not a member yet? Register   Sign In
Change the main content per controller change
#2

Make a MY_Controller (in application/core).
Create a method in it that renders the pages, the way you want.

PHP Code:
class MY_Controller extends CI_Controller {

    public 
$data = array();

    function 
__construct()
    {
        
parent::__construct();
    }

    protected function 
render_page($view)
    {
        
$this->load->view('inc/header_sidebar');
        
$this->load->view($view,$this->data);
        
$this->load->view('inc/footer_sidebar');
    }    



Let all your controllers extend this MY_Controller.
If you want to load a certain page with the default header and footer, just use $this->render_page('viewfile-name');
All the data that you want to pass to the view, can be added to the $this->data array, like:
PHP Code:
$this->data['records'] = $this->sample_model->get_all(); 
Reply


Messages In This Thread
RE: Change the main content per controller change - by Wouter60 - 07-29-2017, 11:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB