I've been working with Drupal for almost 2 years now, mostly building small websites and custom modules for customers.
I turned a small script I often use in small projects into a module : a simple newsletter subscription block. In short, it activates a block containing a form with only two fields : a text field (validated as an e-mail address), and a submit button. When a site visitor submits a new e-mail address, a trigger is ... triggered so the site administrators can configure an e-mail action to send the form data to somebody.
This is nothing new in Drupal, you can already accomplish this using the Webform module together with the node_blocks module. Except that for small projects, Webform can really be an overkill. My module is addressed to new users and web designers that don't have the time or the budget to spend configuring Webform, its public interface, etc. I use it quite a lot, for that same reason : it's really simple and it works out of the box.
For it to be useful to community members I added a few functionalities to it :
1) The administrator can configure a block header, footer, the fields' labels and contents, and even a small text added to the e-mail input field using JavaScript. This text only appears when the field is empty, and its replaces nicely the field label for those who have little room for a regular form. (see the snapshot)
2) It integrates really nicely with the Token module : the administrator can use the submitted e-mail address as a token (in e-mail actions, for example), and can use global tokens in almost every field available in the block configuration form. This is optional though, as my module also works with the core e-mail action.
3) For more advanced users, the module proposes a hook (hook_simple_subscription), so that the e-mail address can be added to a newletter management application by some other script or module.
4) I tried to comment it quite extensively, so that newbies can easily adapt the code for their own needs.
You can download the Finished Module<:a> (well, I'm sure small bugs are still hiding somewhere, but it supposed to work is most situations) as well as a Snapshot of the configuration page and of the block as it is presented to the user.
As I said, this is a really simple module that tries to do what it is supposed to, nothing more, nothing less.
My plan is to keep it in dev module for a month or so, get some user feedback, solve all the bugs, add some of the requested features (if any) and then release the first finished version.
Have fun !
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | simple_subscription.tar_.gz | 4.84 KB | gaspaio |
| #7 | simple_subscription.tar_.gz | 4.92 KB | gaspaio |
| #1 | simple_subscription.tar_.gz | 25 KB | gaspaio |
| #1 | Simple_subscription.png | 229.61 KB | gaspaio |
Comments
Comment #1
gaspaio commentedoops, there was a problem with the download link. You'll find the files attached below.
Comment #2
gaspaio commentedChanged the status to needs review
Comment #3
avpadernoHello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review the code, pointing out what it needs to be changed.
As per requirements, the motivation message should be expanded to contain more features of the proposed project. For themes, it should include also a screenshot of the theme, and (when possible) a link to a working demo site; for modules, it should include also a comparison with the existing solutions.
Comment #4
avpadernoAs reported in Documenting hook implementations:
hook_install(), orhook_enable().That is already done by Drupal core code, as far as I can see.
check_markup()should be eventually called when the content is output, not when it is saved in a Drupal variable.The first argument of
t()is a literal string, not a concatenation of strings. The script used to create the translation template is not able to handle any dynamic value, even in the case of code similar tot($variable); this means that if the argument of the function is not a literal string, it will not appear in the translation template.A form submission handler doesn't use
drupal_goto(), nor returns any values.Comment #5
gaspaio commentedOk, thanks for the detailed review, i'll read it in detail and do the necessary changes !
Comment #6
avpadernoSee also what I reported in comment #3.
Comment #7
gaspaio commentedI reviewed all your comments and changed almost everything you suggested. Thanks again.
The only thing I didn't change is issue 4 in #4. By default, Drupal doesn't seem to remove the block instances from the 'blocks' table when we uninstall the module. At least that's the result I get when I look at the table before and after the uninstall process without the query. Drupal should probably do it, but it doesn't, if I'm not mistaken.
As for #3, you can find a working demo (out of the box, non themed) Here.
As I mentionned before, we can get the same results by combining Webform with Nodeasblock : my module is much simpler than Webform for this specific usage. It is also a lot less intrusive as it makes no changes to the database, and is really easy to theme. It is supposed to be used almost out of the box in simple sites.
For more elaborate uses, developeurs can use the hook my module provides to get the form result and process it according to their needs.
I don't provide any notifications with my module : this is actually a feature, since users can use any notification related actions provided by other modules to pass the form result onto site editors (for example, they can use the Action email role to notify a group of users).
I am willing to add more features to simple_subscription but I'd like to get some user/tester input first. I don't think I should add a lot more though : for complicated forms, site administrators should probably use Webform or build their own custom module.
Comment #8
avpadernoNone of the Drupal core modules that define a block remove the references to their blocks from the blocks database table.
See poll_uninstall(), book_uninstall(), and forum_uninstall().
Comment #9
gaspaio commentedIndeed. Can anybody tell me why ? It seems to me that this is only polluting the database, but I'm sure there is a logical reason for this ...
Anyway, here's the module with all the corrections above and no query in the uninstall function.
Comment #10
gaspaio commentedAny news on the validation of my module proposal ? I'd like to get the ball rolling on this and get some user input :-).
Comment #11
avpadernoComment #12
avpadernoThank you for your contribution! I am going to update your account.
These are some recommended readings to help with excellent maintainership:
You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
I thank all the dedicated reviewers as well.
Comment #13
avpadernoComment #16
avpaderno