Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
404 with controller_template
  • Hi I have the following:
    class Controller_Front extends Controller_Template
    {
    /**
         * The 404 action for the application.
         *
         * @access  public
         * @return Response
         */
        public function action_404()
        {
            $this->page_title = __('label.page_not_found');
            $this->template->content = \Response::forge(\View::forge('404'), 404);
        }
    }

    The page is showing, but when I look in my chrome element inspector I see a 200 status code is being sent... This is not correct I think... How can I fix this?

    Thanks
  • You're mixing two techniques.

    If you're using templates, and you want to assign a partial, assign a View object, not a Response object. If you return a Response object (and optionally a status), the template will be ignored.

    So if you want to set the response status, you'll have to combine the two:

    $this->template->content = \View::forge('404');
    return \Response::forge($this->template, 404);
  • Yup you're right! Thanks

Howdy, Stranger!

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

In this Discussion