Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Nesting Views
  • Nesting Views from http://fuelphp.com/docs/general/views.html, method 1 i 2 not working.
  • Method 1 will never work, since all sections of the layout (and the layout itself) are separate view objects.
    Variables set are not global, they are only known to the object you set them on (in this case $view). If you need global variables, you have to use the set_global() method. Method 2 still uses "$this->output", which has been replaced by "$this->response->body". The documentation has been updated at this point, but for some reason the hook that automagically updates the dev-docs site doesn't work at the moment.
  • I found solution for 1 method:
    $data['title'] = 'Home';
    $view->head = View::factory('head', $data);
    
    $this->response->body = $view;
    

    That's working ;)
  • After replace "$this->output" by "$this->response->body" method 2 works too. Thanks for yours help and time.
  • There are basically two options for method 1:
    - pass all variables needed by the view to every view (like your solution)
    - pass all variables as global so they are available in all views (like I put in the docs) Both work, it depends on your implementation which approach is the best.
  • What is doesn't work? Any error? Have you tried http://fuelphp.com/dev-docs/general/views.html ?
  • ErrorException [ Notice ]: Undefined variable: title
    APPPATH/views/head.php @ line 1

Howdy, Stranger!

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

In this Discussion