I am trying to include a header in my application.I created a controllers site and defined a function header in it, which renders the data variables to views/header.php
However, when i try to access myUrl/site/header all varialble work fine but when i create another function in site controller index and include views/header in that, and i run site/index then i get Undefined variable notices in the header.
Any Idea??
class site extends CI_Controller {
function header()
{
$data =array('name'=>'foo');
$this->load->view('includes/header',$data);
}
function index()
{
$this->load->view('includes/index');
}
}
INDEX.PHP
$this->load->view('includes/header');
Got it Solved!!!!
Wrote a new helper and returned the data from there, then passed the data to view using load->view(‘includes/header’,$data);