Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing properties from parent controller to child controller in Kohana 3
    text
    copied!<p>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. My code is similar to following:</p> <pre><code>class Controller_Facebook extends Controller_Template{ public $template='template'; public $facebook; public $session; public function __contstruct(){ include_once(dirname(__FILE__)."/facebook_class.php"); global $facebook; $facebook = new Facebook(array( 'appId' =&gt; 'xxxxxxxxxxx', 'secret' =&gt; 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 'cookie' =&gt; true, )); $this-&gt;facebook=$facebook; $this-&gt;session = $facebook-&gt;getSession(); } } </code></pre> <p>Then in Home_Controller :</p> <pre><code> class Controller_Home extends Controller_Facebook{ public function __contstruct() { parent::__contstruct(); } public function action_index() { global $facebook; $this-&gt;template-&gt;content=new View('home'); $this-&gt;template-&gt;selected='home'; var_dump($this-&gt;facebook); $this-&gt;template-&gt;app_id='123'; var_dump($facebook); $this-&gt;template-&gt;session=$this-&gt;session; } } </code></pre> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload