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

(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!

//Life motto
if (sad() == true) {
     sad().stop();
     develop();
}
Reply


Messages In This Thread
RE: Best way to load header and footer once globally? - by HarrysR - 10-02-2018, 07:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB