After a short chat with rfay, hi mentioned that we should give some kind of sync between d6 and d7 versions of the examples. On the other hand, d7 provides more features or new implementations of them, so this probably would lead to have different implementations in both branches.
Now that I just put that in, I'm being confused by the triggers_example module, because it is a mix of triggers, actions and hooks. There is more actions code than triggers code in that file, and actions are not explained, neither the hook system. Just to clarify: it includes ping / pong triggers, actions and hooks, all of them in one file.
Does it worth to write a new one, smaller and more focused on triggers, and separate actions and hooks in other example module?
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | examples.trigger_d7_681578_03.patch | 23.86 KB | rfay |
| #3 | examples.trigger_d7_681578_03.patch | 50.99 KB | rfay |
| #2 | trigger_example_d7.patch | 21.16 KB | ilo |
Comments
Comment #1
rfayI'm not committed to synching the D6 and D7 versions.
In fact, I just made the D7 batch example quite a lot smaller and have no intention to do that with the D6 version.
Sometimes it's better to move along.
In all of these, though, we want clear, simple teaching examples that a developer can download and experiment with and understand in as little time as possible.
Comment #2
ilo commentedoh, finally I took the time to finish this one. I've simplified the code from D6 to D7 a lot, not it is simpler but includes more information and examples.
The module defines three triggers:
- ping trigger, is a custom one, should be fired by clicking a button in a example form page. No hook is associated.
- a Mail trigger, runs everytime an email is sent by Drupal.
- a new user trigger: User first time login, only runs the first time a user logs in.
First time login can use any 'user' available actions, the rest of examples only can handle system actions, because they are working with any trigger.
To test them, just create a "Display a message" action, and associate with each different trigger. Submit a mail using contact form, login with a user for the first time or just go to example form and click 'run Ping event' button: the message should be set.
As now the module include no actions, I guess a new 'Actions example' module should provide additional and focused information.
Also, following up:
#659836: trigger categories other than node, user, taxonomy or system don't show up in triggers page.
#659838: trigger help for system group is not generic.
And I'm not sure, I want someone to test it also, clicking logout does not alter the $user->access timestamp. To test it, just configure the "user first time login" trigger to display a message, create a user, login (the message appears), click logout, login again (the message appears), click logout, login again (the message appears), click any link, click logout, login again and the message no longer appears.
I'll be testing this in a few days.
Comment #3
rfayThanks so much for your work on this ilo. I finally took the time to work it over.
I made a number of changes, fixed up the commenting, etc.
I did remove the email example, as it seemed to mix too much stuff together. I don't want people having to understand drupal_mail to be able to understand triggers. It's hard enough as it is.
Comment #4
rfayThe previous patch included a bunch of other cruft. Here's the right stuff.
Comment #5
rfay#4 passed the bot (despite the fact that the bot did not report back) so I'm committing: http://drupal.org/cvs?commit=326848
Thanks for the incredible work on this, ilo. Sorry it took so long to get back to it.