DOCUMENTATION

Search »

Hooks Methodology

Hooks are stored in the hooks table in the database. As a module developer, it's your responsibility to "register" them - i.e. add them to the database table so that they get processed at the locations / times you want.

The benefit of storing them in the database prevents the need for the Core code to import all module code files for each request and process them each individually - which can slow down the script. Instead, this lets the code know precisely which module hooks need to be executed for which function.

For code hooks, the following information is needed:

Module folder name
As described.
Core function
Which function in the Core you want to extend.
Hook function
The name of the function that you want to be called (see here for a list of available code hooks).
Location
Different functions allow hooks at different locations. This is a string denoting the location where your hook should be called (again, see the available hooks page for the locations available for each function).
Priority
(optional) a value of 1-100, with 1 having the highest priority. This determines the order in which multiple hooks associated with the same core function get processed.

Form Tools comes with functions to add, retrieve and delete your hooks. Generally, the best approach to registering hooks is to register them in your installation function. However, you can register them "on the fly" within your own module, based on user input if that is more appropriate to your needs.