Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Variables through functions, the Fuel way
  • I've setup a base controller called public which loads up the language files I want and the template. I want to add things to the template as I go along, starting in the before() then into other controllers. My normal way of doing it is to use $this->view->title = 'hello'; then in the other controllers, $this->view->content = whatever... Is that correct? I've noticed an absence of $this, so can't help feeling I'm doing something wrong.
  • In Fuel you can set a template variable in a controller with :
    $view = \View::factory('view_name');
    $this->response->body = $view;
    

    Or you can use View::set_global() if you want to set variable from before() function Please, check the documentation : http://fuelphp.com/docs/classes/view.html
  • Controllers are still instantiated, you can add as many properties to them as you like (just don't overwrite $this->response or $this->request) and call them using $this->property.

Howdy, Stranger!

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

In this Discussion