[eluser]Phil Sturgeon[/eluser]
Its not too easy setting default variables in a hook as hooks dont return data without setting a session var or something.
Try making a base class. This basically involves making a class called something like BaseController or Globals or something. Try one like this:
Code:
<?
class Globals extends Controller {
var $data = array();
// Chuck everything in here.
function Globals()
{
if(isValidUser()):
$this->data['current_userID'] = getUserProperty('id');
// Chuck in any "All Pages" Data here...
endif;
}
}
?>
Then in your other controllers, instead of extending Controller you extend Globals like so:
Code:
<?
include(APPPATH.'controllers/globals'.EXT);
class Normal_controller extends Globals {
function index()
{
$this->load->view('someview', $this->data);
}
}
?>
Everything in the $this->data which is created in Globals will be available in any of its child controllers, and in any views that are passed the $this->data variable.