1. Setting your autoload.php file like this (this file located in folder application/config/autoload.php)
$autoload['helper'] = array('url');
i used that filter bacuse need it to load css file.
2. Create controller file example home.php and create code like this
class Home extends CI_Controller
{
public function index()
{
//load helper url
$this->load->helper('url');
$this->load->view('theme/header');
$this->load->view('theme/sidebar');
$this->load->view('theme/content');
$this->load->view('theme/footer');
}
}
3. Create css file for example style.css, css file located in theme folder, folder theme located same with application folder, and create code like this
.mainpage
{
width:900px;
margin:0 auto;
padding:0 auto;
}
.header
{
width:900px;
margin-top:10px;
height:50px;
background:#ffccDD;
}
.header h1
{
padding-left:4px;
}
.main
{
width:900px;
margin-top:10px;
}
.main .sidebar
{
width:300px;
float:left;
margin-right:4px;
padding-right:4px;
background:blue;
}
.main .content
{
width:590px;
float:left;
background:red;
}
.footer
{
width:900px;
margin-top:10px;
background:#CDCDCD;
}
4. Create View, my view theme located in theme folder. I split my theme into sections, such as header, sidebar, content and footer.
This is my code in header.php file
This is my code in sidebar.php file
This is my code in contet.php file
This is my code in footer.php file
Title: How to use template in codeigniter
Posted by faisal
Thanks for reading about How to use template in codeigniter
Posted by faisal
Thanks for reading about How to use template in codeigniter