Reputation: 4914
I m new to CodeIgniter so i m facing some problem regarding adding contents from one view to another. I have three views header, contents and footer and want to put these views in one main container with 960px width.
coz i m new so expecting some simple answer.
My code is this
public function index()
{
$this->load->view('header');
$this->load->view('content');
$this->load->view('footer');
}
Thanks
Upvotes: 0
Views: 982
Reputation: 25445
Just call the views inside the main view
public function index()
{
$data['content']['title'] = 'title';
$data['content']['body'] = 'body';
$this->load->view('layout',$data);
}
In views/layout.php
<div id="main_container">
<?php
$this->load->view('header',$content);
$this->load->view('content',$content);
$this->load->view('footer');
?>
</div>
Ex. in views/header.php
<title>.<?php echo $title;?></title>
in views/content.php
<div id="main_body"><?php echo $body;?></div>
Upvotes: 1
Reputation: 6114
function index()
{
$data['title'] ="Details";
$this->load->view("headerview",$data);
$data['batches'] =$this->detailsmodel->getname();
$this->load->view('content',$data);
$this->load->view("footerview");
}
// something similar to this ?
Didn't understand ur question properly brief what u want ? is this the answer u looking for
Upvotes: 0
Reputation: 1917
You need this.
$output = $this->load->view('header', 'your_data', true);
$output .= $this->load->view('content', 'your_other_data', true);
$output .= $this->load->view('footer', 'your_last_data', true);
$this->output->set_output($output);
For more Info
Upvotes: 1