Welcome Guest, Not a member yet? Register   Sign In
Using sessions and setting variables in pre_controller hook
#2

[eluser]Phil Sturgeon[/eluser]
I used to try doing this with pre_controller hooks but came across a better way posted here by a user I forget.

The exact same effect can be done via extending the controller class. Its a little less beautiful but it works a treat.

Make MY_Controller.php and inside it do code such as:

Code:
<?php
class MY_Controller extends Controller {

var $data; // This will be used instead of $data in to be passed to your views

function MY_Controller {
  parent::Controller();

  $this->data->menu = 'foo';
}

}
?>

Then this $this->data->menu work throughout your controller and can be passed to views as well.


Messages In This Thread
Using sessions and setting variables in pre_controller hook - by El Forum - 09-08-2008, 07:29 AM



Theme © iAndrew 2016 - Forum software by © MyBB