Voting starts in March for the Drupal Association Board election.
In the video
- What is a trigger?
- What is an action?
- How do I enable triggers? (slide)
- How do I enable triggers? (demo)
- What can I do with actions and triggers?
- Example 1 (slide)
- Example 1 (demo)
- Example 2 (slide)
- Example 2 (demo)
- Example 3 (slide)
- Example 3 (demo)
- 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)
- Login to your Drupal administration panel
- Go to the Administer page
- Select the Modules section
- Scroll down the page to "Trigger" on the list. Tick the box adjacent to it and then click "Save configuration" at the bottom
- 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)
- Login and go to the administer page as before
- Go to the "Actions" page - we need to make the "Promote to front page action"
- 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.
- Go back to the administer page and then go to "Triggers".
- 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.
- 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)
- Go to the Administer page, and then go into the "Actions" section. Scroll down - we will be using a customized option this time.
- In the menu, select "Send e-mail..." and then click "Create".
- 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!
- 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.
- 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.
- You will return to the Actions page. Scroll down to see your new action. Head back to the "Administer" page now.
- Go to the "Triggers" page, as we now need a trigger.
- This one is in the "Comments" tab, as opposed to the comment tab. Click "Comments" near the top.
- 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".
- 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)
- Go to your "Administer" page and then go to Actions.
- 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.
- 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".
- Go to the "Triggers" page now - you can use the link at the top of the "Actions" page.
- For this one, you need to use the "Users" tab. Click on "Users".
- 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.
- You will now receive an email when a new member joins.
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.