Passing properties from parent controller to child controller in Kohana 3?

Do not overload construct blindly, it will break your controllers. You should be doing this in the before() method. Be sure to call parent::before() after you are done And that global stuff is totally unnecessary.

Just set $this->facebook and then access it later with $this->facebook.

Do not overload __construct blindly, it will break your controllers. You should be doing this in the before() method. Be sure to call parent::before() after you are done.

And that global stuff is totally unnecessary. Just set $this->facebook and then access it later with $this->facebook.

Can you please clarify – Hafiz Feb 22 at 23:04 oh thanks, that works, thanks a lot and also thanks to stackoverflow :) – Hafiz Feb 22 at 23:13.

You've spelt __construct wrong. Also you don't need to access the global if you've set it as a class property. Just access it with $this->facebook.

Oh yes, what the bad mistake I did – Hafiz Feb 22 at 22:31 by correcting this it is saying now this error: ErrorException Fatal Error : Call to a member function body() on a non-object it shows error here: public function after() 41 { 42 if ($this->auto_render === TRUE) 43 { 44 $this->response->body($this->template->render()); 45 } 46 in SYSPATH/classes/kohana/controller/template. Php 44 47 return parent::after(); 48 } – Hafiz Feb 22 at 22:46 Its because of your constructor. Move it code to a public function before() and don't forget to add parent::before() call.

– biakaveron Feb 23 at 13:03.

IMO, it will be better to create Kohana wrapper for FB class, and then use it in your controllers. Like this: $this->facebook = Facebook::instance(); // wrapper will automatically load config with appId etc $this->session = $this->facebook->get_session(); PS. May be Kohana already has this implementation?

Something like https://github. Com/zombor/Kohana-Facebook.

I am using Kohana 3 and using a middle controller named controller_Facebook that is extended from Controller_Template and then extending Controller_Home from Controller_Facebook. I am setting two properties in Controller_Facebook and trying to use them in Controller_Home but it not available there. It gives null value.

Also if I echo some thing in parent class then it doesnot output that. It working in facebook also so does that mean that my parent constructor is working? I think it is working.

Please tell me if some one think that I am doing some thing wrong.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions