[eluser]zauber[/eluser]
I needed something similar for some authentication code I'm working on.
I ended up going with setting the exception handler to a function of my own, then throwing an custom exception. In the exception handler, you still have access to the CI object and all it can do, but you're not executing your controller anymore.
Since exceptions take you out of the main CI flow, you don't get the part where it pushes the output buffer at the end. You could
probably call that yourself though, or just load a view with true and echo it.
So something like this, perhaps:
Code:
function index() {
//yada yada... decide to fail:
$this->_exit();
}
function _exit() {
set_exception_handler(array($this, '_exit_handler'));
throw new Exception(); //at this point, we completely jump out of executing our controller, and can't come back.
}
function _exit_handler() {
restore_exception_handler();
echo $this->load->view('my_view', array(), TRUE);
}