Welcome Guest, Not a member yet? Register   Sign In
data __construct inside a controller
#1

[eluser]coolant[/eluser]
I'd like the ability to have $data be used in all of the methods automatically without having to define it in each method. This would be how I would do it in non-CI. I tried creating a method called Home and putting the $data['cow'] in there, but no such luck.

Also, can I use $this->load inside this "construct" ?

Code:
class Home extends Controller {

public $data;

function __construct()
{
  $data['cow'] = 'moo';
}

function foo()
{
  $this->load->view('foo', $data);
}

function bar()
{
  $this->load->view('bar', $data);
}

}

Thanks!


Messages In This Thread
data __construct inside a controller - by El Forum - 12-04-2008, 09:33 PM
data __construct inside a controller - by El Forum - 12-04-2008, 09:58 PM
data __construct inside a controller - by El Forum - 12-04-2008, 10:06 PM
data __construct inside a controller - by El Forum - 12-04-2008, 10:14 PM
data __construct inside a controller - by El Forum - 12-04-2008, 10:23 PM
data __construct inside a controller - by El Forum - 12-04-2008, 10:29 PM
data __construct inside a controller - by El Forum - 12-04-2008, 10:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB