Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Send variables from base controller to normal controller (and back)
  • Let's say my base controller, Controller_website, on which every normal controller extends, generates some data which I need in the most controllers. What is the best way to get those variables to every controller? In CodeIgniter I use:
    $this->load->vars($data);
    

    And I was able to use the in the MY_Controller generated variables in every controller. I know about $this->template->content->set() but I need the variables in the controller, not in the view.
  • Oh it's great once you learn it :) I just picked it up after quitting PHP at 4.3... so much better IMO.
  • Create a Controller_Website controller that extends \Controller_Template... All other controllers will extend Controller_Website... add a public variable to Controller_Website and have it automatically set in the before() method... Should work for you. :)
  • Ya, basically what nerdsrescueme said. Create a protected (possibly public) variable on one of the classes (NOT both). Then just set/get that variable. Dan
  • Thanks, so simple! Still learning PHP5...

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion