I’m repeatedly having to include one variable when I display my views:
$this->load->view('login', array('logged_in' => $this->auth->is_logged_in()));
$this->load->view('somepage', array('logged_in' => $this->auth->is_logged_in()));
$this->load->view('anotherpage', array('logged_in' => $this->auth->is_logged_in()));
How can I include this one variable across all of my view outputs? Is there a simpler method than extending the templating class?
One simpler way would be to make the array into a variable, so you dont have to type it out all the time, e.g.
An alternative would be to create a Helper that returns whether a user is logged in. Helpers are globally available in your controllers and views. See http://codeigniter.com/user_guide/general/helpers.html and also