Book Image

Learning Drupal 6 Module Development

Book Image

Learning Drupal 6 Module Development

Overview of this book

Table of Contents (14 chapters)
Learning Drupal 6 Module Development
About the Author
About the Reviewers

Defining a Hook

We have been examining hooks since the first chapter of this book. Now we are going to take an in-depth look at how a module can implement its own hook.

In this section, we will invoke a custom hook, implement that hook in other modules, and look at the mechanics of using hooks.

The goal of defining this hook is to make it possible for other modules to earmark content for inclusion in a site news message. This gives the module developers the ability to specify what content should be included in a report, and how it should appear.

We will start out by backtracking. Let's take another look at the hook invocation from the last section.

Invoking a Custom Hook

In the last section, we took a look at this line of code (called in sitenews_send_action()):

$content = module_invoke_all('sitenews');

The Drupal module_invoke_all() is one of the main hook functions. Its job is to call all the hook implementations for a specific hook. It searches all of the enabled modules looking for functions...