2

In basic terms what are hooks,actions and triggers.

My ideas are that hooks allow you to do something when an event takes place and that the "something" is the action.

I am having a bit of trouble figuring out where triggers fit into the equation.

4

Hooks are one concept, and actions-and-triggers are a separate concept.

See What is the basic concept behind hooks? for the canonical explanation of hooks (there are some excellent answers to that question, there would be no point in trying to reproduce them here).

Actions and Triggers are best explained in Using the new Actions and Triggers functions in Drupal 6 (the concept is the same for Drupal 7).

From that page:

What is a trigger?

Triggers are Drupal events such as saving or updating a post, a user logging in or someone viewing a piece of content. Think of it like a trigger for an argument – when the trigger happens (ie. A disagreement), an Action happens (the argument). This allows you to heavily customize Drupal and paves the way to amazing new implementations of the software.

What is an action?

Actions are something that happens after the trigger. For example, you could redirect the user to a page, send an email notice to administrators or display a special message. This can allow you to integrate Drupal into other systems.

You might also be interested in the Rules module which is

a replacement with more features for the trigger module in core

It's far more powerful than the trigger module and has a lot of extra features.

1

Triggers are events to which actions can be assigned. For example, if you look at admin/structure/trigger/node (once you have installed the Trigger module), you will notice the following page.

screenshot

Actions are those available from admin/config/system/actions.

screenshot

Triggers and actions are a convenient way to assign actions to system events. They are convenient because they can set through a user interface.

Drupal defines its own triggers, and actions, but third-party modules can implement new triggers, and actions through hook_trigger_info(), and hook_action_info().

As side note, the Trigger module has been removed from core, in Drupal 8. If you need a similar functionality, and you need compatibility with Drupal 8 since now, you should check a third-party module with equivalent functionality.

  • In my humble opinion, this is the best answer. So the only real difference between hooks and the triggers-actions duo is that hooks aren't configurable through the admin UI, while triggers-actions are, correct? – Alexandre Bourlier Aug 20 '14 at 14:17
  • 1
    That is correct: Hooks don't have a page where you can configure them, or select them. – kiamlaluno Aug 20 '14 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.