FUEL CMS User Guide : Version 1.3.2


Module Hooks

FUEL has extended the CodeIgniter Hooks system to provide extra hooks into creating, editing, and deleting of simple module data. An additional module hook parameter was added to allow you to add hook files in your advanced module folders (e.g. fuel/modules/my_module/hooks). To add a hook, you modify the fuel/application/config/hooks.php just like the native CodeIgniter Hooks.

The hooks currently available are:

The {module} part of the hook name is the name of the simple module that the hook applies to. Additionally, the {module} of "module" will be applied to all modules.

The following is an example of an advanced module named "projects" that has a hook file located at fuel/modules/projects/hooks/Project_hooks.php.

$hook['before_edit_projects'] = array(
	'class'    => 'Project_hooks',
	'function' => 'before_edit_projects',
	'filename' => 'Project_hooks.php',
	'filepath' => 'hooks',
	'params'   => array(),
	'module' => 'projects',
);

How Are These Hooks Different Then Model Hooks?

Unlike model hooks, module hooks allow a module to execute code before or after an event in another module. This allows for more autonomous integration between modules. For example, say you want to integrate into the FUEL blog comment module to send an email notification to someone other then the author of the post (which the blog module does automatically). You can add an after_edit_blog_comments hook to the fuel/application/config/hooks.php file to make that happen.