Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Template controller and HTTP header in FuelPHP 1.3-dev
  • $this->response has been removed in Template controller. So how do we set HTTP headers in acontroller exteded Template controller? I wrote my controller which extends Template controller, and wrote $this->response = new Response(); in before() and public function after($response)
    {
    $response = $this->response;
    $response->body = $this->template; return parent::after($response);
    }
    Is there any better ways?
  • Normally you don't have to as it'll always give a 200 code by default. For any errors but still using the template you just return it like this:
    return new Response($this->template, 400);
    

    Once the action method returns anything that will be used instead of the template, in this case simply the template wrapped in a Response object with the 400 status code.
  • Thank you for you reply. I want to set cache controll headers for logged in users.
    So I want to set the code in before().
  • In that case your current solution is probably best.
  • Thank you!

Howdy, Stranger!

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

In this Discussion