Reputation: 9340
I've used a solution from how-to-setup-a-custom-404-page-for-a-kohana-v3-app, thanks to mdskinner. So, my working code is like:
Kohana_Exception::$error_view = 'kohana/404';//bootstrap.php
and the view file path is system/views/kohana/404.php
Unfortunately, the 404 page is a static page. But, I want to load the footer dynamically exactly as it is at any other page - using controller and view. Is that possible for 404 custom page?
Upvotes: 0
Views: 90
Reputation: 7050
In your index.php
, you put a try/catch block between your request execute and your echo, like this
$request = Request::factory();
try
{
$response = $request->execute();
}
catch (Exception $exc)
{
if ($exc instanceof HTTP_Exception && $exc->getCode() === 404)
{
$response = Request::factory('your404route')->execute()->status(404);
} else {
throw $exc;
}
}
echo
$response
->send_headers()
->body();
Upvotes: 1
Reputation: 17725
Yes you can easily. Please use official guide for 3.2 - http://kohanaframework.org/3.2/guide/kohana/tutorials/error-pages or great blog post from Lysender - http://blog.lysender.com/2010/08/kohana-404-pages/ (this is actually for 3.1 version but the changes between 3.2 and 3.1 are not that big).
Upvotes: 0