Hook in Codeigniter ????

Enabling Hooks

The hooks feature can be globally enabled/disabled by setting the

following item in the application/config/config.php file:

$config[‘enable_hooks’] = TRUE;

Defining a Hook
Hooks are defined in application/config/hooks.php file. Each hook is specified as an array with this prototype:

$hook[‘pre_controller’] = array(
‘class’ => ‘MyClass’,
‘function’ => ‘Myfunction’,
‘filename’ => ‘Myclass.php’,
‘filepath’ => ‘hooks’,
‘params’ => array(‘bread’, ‘wine’, ‘butter’)
CLASS-The class that you wish to invoke, if it is procedural code leave it as blank.
FUNCTION-The function name you wish to call.
FILENAME-The file name containing your class/function.
FILEPATH-Location of the hook file.
PARAMS-Additional parameter if needed it is optional

Hook Points
The following is a list of available hook points.
Called very early during system execution. Only the benchmark and hooks class have been loaded at this point. No routing or other processes have happened.
Called immediately prior to any of your controllers being called. All base classes, routing, and security checks have been done.
Called immediately after your controller is instantiated, but prior to any method calls happening.
Called immediately after your controller is fully executed.
Overrides the _display() function, used to send the finalized page to the web browser at the end of system execution. This permits you to use your own display methodology. Note that you will need to reference the CI superobject with $this->CI =& get_instance() and then the finalized data will be available by calling $this->CI->output->get_output()
Enables you to call your own function instead of the _display_cache() function in the output class. This permits you to use your own cache display mechanism.
Called after the final rendered page is sent to the browser, at the end of system execution after the finalized data is sent to the browser.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Rajnikant Boghani

The greatest facebook.com site in all the land!

R@j @h!R

Talk is cheap. Show me the code.


A fine WordPress.com site

Azeem Rangara

Top IT Technology Funda

Welcome to Adarsh Patel's Blog

Learning is the Key To Success.

The Daily Post

The Art and Craft of Blogging

The WordPress.com Blog

The latest news on WordPress.com and the WordPress community.

%d bloggers like this: