/
hooks_methodology.html
93 lines (81 loc) · 2.75 KB
/
hooks_methodology.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
layout: default
navPage: docs
heading: Hook Methodology
breadcrumbs:
- Module Development,/module_development/
- Form Tools 3,/module_development/ft3/
- Hooks,/module_development/ft3/hooks/
- Hooks Methodology
prev: Hooks,/module_development/ft3/hooks/
next: Code Hooks,/module_development/ft3/code_hooks/
categories: module_development
versions: FT3
---
{% include open_section.html nav='nav_module_development_ft3.html' selected='hooks_methodology' nav_width=4 %}
<p>
Hooks are stored in the <b>hooks</b> 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.
</p>
<p>
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.
</p>
<p>
For code hooks, the following information is needed:
</p>
<div class="row">
<div class="col-lg-3">
<strong>Module folder name</strong>
</div>
<div class="col-lg-9">
As described.
</div>
</div>
<div class="row">
<div class="col-lg-3">
<strong>Core function</strong>
</div>
<div class="col-lg-9">
Which function in the Core you want to extend.
</div>
</div>
<div class="row">
<div class="col-lg-3">
<strong>Hook function</strong>
</div>
<div class="col-lg-9">
The name of the function that you want to be called (see here for a list of
<a href="{{site.baseurl}}/module_development/code_hooks/">available code hooks</a>).
</div>
</div>
<div class="row">
<div class="col-lg-3">
<strong>Location</strong>
</div>
<div class="col-lg-9">
Different functions allow hooks at different locations. This is a string denoting
the location where your hook should be called (again, see the
<a href="{{site.baseurl}}/module_development/code_hooks/">available hooks</a> page for the locations
available for each function).
</div>
</div>
<div class="row">
<div class="col-lg-3">
<strong>Priority</strong>
</div>
<div class="col-lg-9">
(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.
</div>
</div>
<p>
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.
</p>
{% include close_section.html %}