This function checks both - the internal and AJAX requests. It might be handy if some parts of the page are initially loaded using HMVC technique, and can be then reloaded with AJAX. Place it withing some base controller, from which you extend all your proper controllers (I call it 'base controller'):
public function is_remote()
{
if ($this->request->is_initial())
{
if ($this->request->is_ajax())
{
return TRUE;
}
else
{
return FALSE;
}
}
else
{
return TRUE;
}
}
A shorter (equivalent) way of writing this:
public function is_remote()
{
return ( ! $this->request->is_initial() || $this->request->is_ajax());
}
Hope this helps.
If you need to display an error page, Kohana has built in exceptions for it. Once you've thrown an exception, you can create a custom exception handler and have a HTML error page shown. You'll want a switch to show the real error in development.
throw new HTTP_Exception_404('The article :article was not found',
array(':article' => $article->name));
The 2nd argument provides a way for you to replace strings in the error message.
Doesn't have HTTP exceptions bundled. You should create your own exceptions and handle them. Kohana has a tutorial for this: Kohana - Custom Error Pages