Hooks

Any programmer can edit the Form Tools Core code to make whatever changes they need, but the drawback is that any time they do this, they run the risk of having those changes overwritten the next time the script is upgraded. This is a problem!

Enter Hooks. Hooks are a solution employed by many extensible web applications to solve this situation (or at least patch it!). Hooks can be implemented in a wide variety of ways, so the following pages outline our approach.

Hooks let programmers do two things: (1) have their code executed at certain locations (code hooks) and (2) have their own HTML displayed in the main Form Tools webpages (template hooks). When combined, this opens up a wide range of functionality that was previously impossible to do safely. Let's take a closer look at each of these hook types.

Code Hooks

Littered throughout the Form Tools code - mostly found in getter and setter functions - there are numerous code hooks, where module developers can attach their own code. If you're looking through the code, look for lines like this:

extract(ft_process_hooks("main", compact("account_info"), array("account_info")), EXTR_OVERWRITE);

Basically what this does it pass off execution control to the ft_process_hooks function, which calls all custom module functions that have been assign to the hook ("main", uniquely identified by the calling function). It specifies what variables are passed and what may be overwritten. For a full list of code hooks and what variables are passed and overridable, click here.

Template Hooks

Template hooks are probably simpler to understand. In the Smarty templates, there are a number of locations where module developers may have their own HTML inserted into the page. This can let you do things like add fields to forms, insert information or text for the benefit of the user, or anything else. Template hooks look like this:

{template_hook location="admin_edit_client_settings_top"}

For a list of template hooks, click here.

Edit Page