[eluser]Prophet[/eluser]
Hi all. I have a method in MY_Controller which is used extensively throughout other child controllers. A problem I have come across is that if I call $this->load->vars() in MY_Controller, the child controllers don't seem to inherit the variables? Example:
Code:
class MY_Controller extends Controller
{
public function my_function()
{
$vars['title'] = 'Title';
$vars['greeting'] = 'Hello';
$this->load->vars($vars);
}
}
Code:
class Welcome extends MY_Controller
{
public function index()
{
$this->my_function();
$this->load->view('welcome');
}
}
I expected the 'welcome' view to inherit $title and $greeting... But it doesn't. Is there any way I can get this to function as I expect? Or will I have to do something like:
Code:
class MY_Controller extends Controller
{
public function my_function()
{
$vars['title'] = 'Title';
$vars['greeting'] = 'Hello';
return $vars;
}
}
Code:
class Welcome extends MY_Controller
{
public function index()
{
$vars = $this->my_function();
$this->load->vars($vars);
$this->load->view('welcome');
}
}