Create your own hooks for Drupal module development

Source: Internet
Author: User
Tags drupal
Drupal allows third-party modules to create their own hooks. In general practice, there are two types of hooks you may want to create, one is the content modification class hook, the other is the interception class hook. Drupal's hook system allows interaction with modules and changes the logic of other modules.... Drupal allows third-party modules to create their own hooks. In general practice, there are two types of hooks you may want to create, one is the content modification class hook, the other is the interception class hook.

Drupal's hook system allows interaction with modules and changes the logic of other modules, or even changes the core logic of Drupal. This is a very simple system, and even allows third-party modules to create their own hooks. In general practice, there are two types of hooks you may want to create, one is the content modification class hook, the other is the interception class hook. The hook of the modify class provides a standard method to modify the content of a specific object or variable. Typically, the drupal_alter () function is used. The interception hook allows a third-party module to perform certain actions according to the conditions during Module execution.

Example 1: Simple call

 

Example 2: aggregation result

 

Example 3: Use drupal_alter () to change the content

  'value1','key2' => 'value2',);// will call all modules implementing hook_my_data_alterdrupal_alter('my_data', $data);?>

Example 4: reference parameter passing. module_invoke cannot be used.

 


Tutorial address:

Reprinted! But please include the article address ^

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.