Reputation: 83
Hi can anyone let me know which is the best way to use the header footer in codeigniter? The way below seems to be troublesome to put into each function to display header footer
$this->load->view('header');
$this->load->view('content', $data);
$this->load->view('footer');
Also i browse around the web i see some people do the loading of header and footer functions in the Core controller. Anyone have any idea how to do it?
Please advise anyone.
Upvotes: 2
Views: 7140
Reputation: 334
I have created a repo CodeIgniter-Assets on github to solve custom header/footer problem with codeigniter which is really easy to configure I hope this will solve your issue.
Upvotes: 0
Reputation: 5809
in your core controller create a method & load your header view
& footer view
public function load_view($view, $vars = array()) {
$this->load->view('header', $vars);
$this->load->view($view, $vars);
$this->load->view('footer');
}
in your controllers, call
$this->load_view('my_view', $view_data);
if you don't need header & footer (for example ajax views), you can normally call
$this->load->view('my_ajax_view', $view_data);
Upvotes: 5