You can do this in KO2 quite easily with hooks. If you look at events you'll find system.404
which you'll need to replace using something like:
<?php defined('SYSPATH') or die('No direct script access.');
// Replace the default kohana 404
Event::replace('system.404', array('Kohana', 'show_404'),
array('hook_404', 'show'));
class hook_404 {
public function show()
{
// first param is URI of page, second param is template to use
Kohana::show_404(FALSE, 'custom_404');
}
}
Save this in the hooks directory in your app folder (or in a module). Don't forget to enable hooks in your config:
$config['enable_hooks'] = TRUE;
And add your custom 404 view: views/custom_404.php
.
Note: these won't display if you have $config['display_errors']
set to FALSE
in your config.php
(which it probably should be if you're IN_PRODUCTION right?). For that you need to output something and die eg. replace Kohana::show_404
with the following:
require Kohana::find_file('views', 'custom_404');
die();