Skip to main content

Hooks in Drupal 7

Hooks, also called callbacks, can be described as internal Drupal events. Hooks essentially allow Drupal modules to hook into the rest of the Drupal installation.

Hooks Drupal

Creating and validating Forms for Advanced Actions in Drupal 7

The first function in the code below describes the form to drupal. The only form defined is a text field. The text field will be used so that the admin can designate the number of beeps.

Modules Hooks Actions Drupal

Creating a simple new module that uses a hook in Drupal 7

The following snippet demonstrates how to create a module in Drupal 7. It will send a message to the log every time new content is created.

Drupal Hooks Modules

Using hook_block_save() in Drupal 7

Save block-specific configuration settings. Configuration settings are defined in hook_block_configure().

Drupal Hooks

Using hook_block_view() in Drupal 7

Hook_block_view() takes in $delta as a parameter. $delta is the unique identifier for the block within the module. $delta is defined in hook_block_info(). It returns an array containing "subject" and "content".

Drupal Hooks

Using hook_block_info() in Drupal 7 Primary tabs

hook_block_info() declares to Drupal what blocks are provided by the module. Initial block configs can be specified. Each block provided by the module is given a unique identifier. The unique identifier is referred to as $delta.

Drupal 7 Hooks

Using hook_block_configure() in Drupal 7

hook_block_configure() takes in $delta as a parameter. $delta is the unique identifier for the block to be configured. The unique identify is defined in hook_block_info(). It returns a configuration form.

Drupal 7 Hooks

Using hook_settings() in Drupal 7

This hook declares admin settings for module. It provides admin interface for controlling settings for module. A menu item for module will appear in admin menu when the hook is implemented. It returns an array containing form items.

Drupal Hooks Modules

Using hook_menu() in Drupal 7

hook_menu() registers paths to define how url requests are handled. It returns an associative array. Its keys define paths. Its values are an associative array of properties for each path.

Drupal Hooks
Powered by Drupal 7. Made by Cody Bonney.