Welcome Guest, Not a member yet? Register   Sign In
Best way to load header and footer once globally?
#4

(10-02-2018, 07:27 AM)HarrysR Wrote:
(09-28-2018, 09:43 AM)Wouter60 Wrote: Create a MY_Controller in the application/core folder.

Inside that controller, create this function:
PHP Code:
protected function render_page($view,$data)
{
 
  $this->load->view('templates/header'$data);
 
  $this->load->view($view$data);
 
  $this->load->view('templates/footer'$data);


Let all your controllers extend the MY_Controller.
Then, to load a page with header and footer:
PHP Code:
$this->render_page('pages/page_name',$data); 

Well it worked! I also loaded a model in there and it works fine! 

Thanks for the suggestion!

Hum hum ... i've got the following error "Message: Class 'MY_Controller' not found". What am I doing wrong ? Should I include the class in each controller ?
Reply


Messages In This Thread
RE: Best way to load header and footer once globally? - by imabot - 10-04-2018, 08:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB