I have recently switched from using Controller_Template to Theme class.
I'm not really sure how can I now handle the errors, like 404.
Using Controller_Template, this was fairly easy since in the controller function I only had to return response object or assign it to the $this->template->content:
What about the Theme class? I got a themes/default/templates/errors/ directory which contains views for common errors.
I was able to generate view like this (I'm using presenter to set a variable, like in the fresh fuel installation). However, this one doesn't set the 404 header.
$theme = Fuel\Core\Theme::instance();
$theme->get_template()->set( 'title', '404 - not found' );
How can I handle errors in my controllers properly? Is there a nice way I could immadiately throw 404 in certain moment, eg. by a simple function call show_404();
Sometimes I have to add some Javascript on my template view, however I don't output the script in the middle of my HTML. For the cosmetics purposes I'd like to output the used Javascript at the bottom of the page (before </body> tag).
To do that, I'm currently storing the raw Javascript code in a PHP variable and queue it to asset, then output render in my layout like this: