Codeigniter钩子重新实现我的类

So I have a template class that I load with the autoloader. I will use this throughout my controllers to load template files. I want to make a post_controller hook so that after the controller is done, the template will be viewed. The problem is that when I use the hook, it just makes a new template class - so it doesn't have the loaded template files.

So, how can I use a class with a hook without reinstantiating the class?

How it's used in a controller:

function index()
{       
    $this->tpl->load('test');
}

My hook:

$hook['post_controller'] = array(
    'class'    => 'Tpl',
    'function' => 'view',
    'filename' => 'Tpl.php',
    'filepath' => 'libraries'
);

Two things, first I would recommend using the display_override hook instead, it makes a lot more sense. See the bottom of this page for more information on how to use it.

Also, if you want to use your class in either, try something like:

$this->CI =& get_instance();
$this->CI->My_Class_Name->SomeMethodOrSomething();