Using the new Actions and Triggers functions in Drupal 6

This is the companion handbook page for the Drupal screencast "Drupal 6: Actions and Triggers" which can be found at http://blip.tv/file/529950 or downloaded as a torrent at http://code.google.com/p/google-highly-open-participation-drupal/issues/.... It contains an outline of what is in the video, slides as images and the text in the video.

In the Video

1. What is a Trigger?
2. What is an Action?
3. How do I enable triggers? (Slide)
4. How do I enable triggers? (Demo video)
5. What can I do with Actions and Triggers?
6. Example 1 (Slide)
7. Example 1 (Demo)
8. Example 2 (Slide)
9. Example 2 (Demo)
10. Example 3 (Slide)
11. Example 3 (Demo)
12. Ending Notice

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.

How do I enable triggers? (Slide)

To begin using Triggers and Actions, you first must enable the Triggers Module included in Drupal 6.0. Follow the following instructions:

How do I enable triggers? (Demo)

1. Login to your Drupal administration panel
2. Go to the Administer page
3. Select the Modules section
4. Scroll down the page to "Triggers" on the list. Tick the box adjacent to it and then click "Save configuration" at the bottom
5. Return to the administer page - a Triggers option should have appeared.

What can I do with Actions and Triggers?

Actions and Triggers are pretty awesome really. They give you the ability to add some extra dynamic features to your Drupal installation without any coding or real technical knowledge.

It’s like writing a new Module for Drupal, but easier. The best thing is that there are so many things you can do! Here are some real world example of things you could do using Actions and Triggers:

Example 1 - Auto Promote to Front Page (Slide)

Ever written a piece of content and forgotten to Promote it to Front Page? It sounds simple, but it gets annoying if you have to go and promote it manually. Using the “After saving a new post” trigger and the “Promote Post to Front Page” action, you can make this happen automagically!

Example 1 - Auto Promote to Front Page (Demo)

1. Login and go to the administer page as before
2. Go to the "Actions" page - we need to make the "Promote to Front Page action"
3. Scroll down to the list of actions - as you can see, there is already a "node" type action called "Promote Post to Front Page". Drupal comes with some predefined actions which will often be helpful. We don't need to customize it in this case. However, look down and be aware of the customizable actions in the drop down menu.
4. Go back to the administer page and then go to "Triggers".
5. Look at the top - there are five types of trigger. Each (current) trigger will be categorised under one of these types. We want the content section, which is shown automatically. We want stories to be automatically promoted when they're created or edited, so we will use the "When either saving a new post or updating an existing post" trigger. Go to the drop down menu below the title, and then select the "Promote post to front page option" and then click Assign.
6. Navigate away and post some content. Once you've written it, open the Publishing section and tell it not to Promote it to Front Page. Click Save, and it will be promoted to the front page anyway! Your action and trigger set is working!

Example 2 - Alert Writer to a New Comment (Slide)

Don’t you just love that warm, fuzzy feeling when you get a comment on something you’ve written? It’s really nice to be appreciated for your hard work. You can get an alert when someone comments on your story using the “After saving a new comment” trigger with the “Send an email” action. In this set, you will be using variables.

Example 2 - Alert Writer to a New Comment (Demo)

1. Go to the Administer page, and then go into the "Actions" section. Scroll down - we will be using a customized option this time.
2. In the menu, select "Send e-mail..." and then click "Create".
3. A new page will appear for you to customize it. Make sure you use a description so you can recognise what one it is - before long you'll have loads of different actions!
4. Look at the "Recipient" field. Below it says that you can put "%author" in the field to send the email to the author of the post, which is what we want to do! Type "%author" into the field.
5. Set a subject of your choice and then put a message into the final field - for example, you could put "You've got a new comment on your story - go take a look!". Finally, click Save.
6. You will return to the Actions page. Scroll down to see your new action. Head back to the "Administer" page now.
7. Go to the "Triggers" page, as we now need a trigger.
8. This one is in the "Comments" tab, as opposed to the comment tab. Click "Comments" near the top.
9. We need the "After saving a new comment" trigger - go to the drop down box in it and then select the Action that you made earlier. Click "Assign".
10. It's done! Now you will receive an email if someone comments on your post!

Example 3 - Personalized Member Welcome (Slide)

Is your site a bit of a niche site with a dedicated fan-base or do you want to really make your customers feel at home? You can get notified when a new member joins so that you can send a customized notice to them personally! Use the “Send email” action with the “After a user account has been created” trigger.

Example 3 - Personalized Member Welcome (Demo)

1. Go to your "Administer" page and then go to Actions.
2. Once again, we need to use the "Send e-mail..." action but this time with the "After a user account has been created" trigger. Scroll down, and then create a "Send e-mail" action.
3. In the Recipient box type your email. Give it a memorable description, in the Subject put something like "New member has joined" and in the message put something like "A new member has joined, remember to email them!". Click "Save".
4. Go to the "Triggers" page now - you can use the link at the top of the "Actions" page.
5. For this one, you need to use the "Users" tab. Click on "Users".
6. Scroll down to the "After a user account has been created" trigger and then in the drop down box select the Action that you just created and then click Assign.
7. You will now receive an email when a new member joins.

Ending Notice

Thank you for watching the Drupal screencast on Actions and Triggers. I hope that this has been useful, and has helped you to understand the new options and use them effectively to improve your site. Visit the handbook page on Actions and Triggers for a text only version of the screencast.

Torrent link not working

jlndrr - May 1, 2008 - 22:34

Te current link to the torrent don't seems to work (anymore ?).

Use this one instead :

http://google-highly-open-participation-drupal.googlecode.com/issues/att...

 
 

Drupal is a registered trademark of Dries Buytaert.