I am new to codeignitor as separating my website into three like header,body,footer I have create header and footer controller and view page.I am facing a problem how to include both the controller in body controller like include('.php') in php
1 Answer
The html for your pages should be in the views, not in the controllers.
Your choices are;
1) create a view for each section, then call them all from a controller
class Foo extends CI_Controller {
public function index() {
$data = array(); // put data in here
$this->load->view('header', $data);
$this->load->view('main, $data);
$this->load->view('footer', $data);
}
2) call others views from the main content view
// in view for html page
<?php $this->load->view('header'); ?>
<h1>My Page</h1>
<?php $this->load->view('footer'); ?>
3) or use a template library, like this one for example
If you really want to go down the controller inside controller routes, look at hmvc for codigniter