Hooks Example
Implementing, defining, and invoking hooks
The code in this module implements a couple of new features which you can see in action.
Implements hook_help()
: In
hooks_example.module
you'll find an implementation of the
hook hook_help()
which is used to add contents to this module's
help overview. Visible at
admin/help/hooks_example
.
View counts: hooks_example_node_view()
is an
implementation of the hook hook_ENTITY_TYPE_view()
that adds a
basic page view counter. You can see this in action by navigating to any node on
the site and looking for the the text telling you how many times you've viewed
that page.
Don't have any nodes? Add some and look at their counters.
Implements hook_form_alter()
: In
hooks_example.module
you'll find an implementation of
hook_form_alter()
which demonstrates the use of one of the most
commonly used alter hooks. You can view the altered form at
user/login
.
To learn more about how to implement an existing hook, or how to define and
invoke a new hook start by reading the @docblock
comments in
hooks_example.module
.