CCK_emailer: the field that is a verb

Events happening in the community are now at Drupal community events on www.drupal.org.
Development Seed's picture

(Please see the attached 4 sketches)

The basic idea of cck_emailer is to create a cck field type that lets you define an email address to which to mail any new node created that implements the specific cck_emailer field type.

How could CCK replace webform, and would you want to even do this? The purpose of this post is to vet an idea. There is no working code yet. This is also not an attack of any kind on the webform module, I'm just using it for comparison of what this would recreate and in order to tell if this would be any better than what the webform module already does.

When looking at the webform module, there are many components which are fields much like cck fields (text, number, file, email, etc.). Webform lets you assign who the form submission (whether that form is a survey, contact form, etc.) gets emailed to.

The email target for a cck_emailer field could be:

static - address(es) defined by the admin when making the cck field
dynamic - defined by the user while they're making the node
nodereference-controlled - based on email fields found on referenced nodes. (this is the harder one to explain, but hopefully the attached mockups do it justice).

Such a functionality, if feasible, could take the place of webform, and could make it easier to implement email-campaigns, like letter to the editor campaigns, where newspapers with associated email addresses are the referenced node type, and letters to the editor are the nodes being created by users and emailed to newspapers.

This assumes making a lot of things nodes, but I see this as the working data model in Drupal and it's not so bad that the content of these nodes are not so strictly content for viewing like on a normal website.

You can then use views for showing the emails that have gone out, and the node that's getting emailed (like a letter to the editor) could consist of whatever cck fields you want. This begs the idea of a node_email_template module, that lets you define a template/format to use when a node is being send through the cck_emailer functionality (something else does the sending, like the send module, or drupal itself) and a node_email_template could be defined by letter the user place %field_name around a textarea much like they define the "forgot your password" email on admin/user/settings.

What's missing from cck_emailer:

emailing attachments?

Possible challenges:

knowing what the node consists of if you're sending it upon submission (maybe do the sending on cron?)
what else can't this do that webform does?

Other ideas:

this could work well with the views_selector module by Mark
could you easily hide the nodereference form and prepoulate it for the user based on a selection they make, like from a views_selector form/list, on another page in Drupal?

AttachmentSize
mailing_a_node_user-entry.pdf13.06 KB
mailing_a_node-node-ref.pdf30.42 KB
mailing_a_node-widget-set.pdf15.78 KB
node_emailer-widget-settings.pdf22.65 KB

Comments

Actions

mfredrickson's picture

I would suggest looking into the actions module. I think that would be the best way to attach behavior (actions) to content (cck types). With actions, you write the behavior (emailing based on a value in a field) and then apply it through another interface (usually workflow) to certain events (e.g. node submission). It is extremely configurable.

For example, check out http://drupal.org/project/fieldactions

Right now, there are only two actions, but take a closer look at "Send an email to a user reference field". I don't think it would be that hard to take this one or two steps farther and create "Send email to address in email field" and "Run action on node reference linked node" (which could run the email action on a linked node, e.g. email the NY Times node).

This solution would require a simple workflow to invoke the action on submission.

On attachments: mimemail.module supports attachments now. With a file field or using the upload files in the node, this could probably be accomplished pretty easily.

On challenges: webform does not create an entire node for each submission. There are pros and cons to this approach. Also, webform allows for easy 1 click CSV downloads of submitted data. A nice feature.

I'm glad you like the view_selector. At my last count there are 384,328,329 different uses for it. Time to add another. ;-)

Thanks for the idea Mark. I

Development Seed's picture

Thanks for the idea Mark. I started wondering along these lines as well using fieldactions. I will take a closer look, it seems to make a lot of sense though.

Nice work w/ view_selector again, it's great!

Ian

mlsamuelson's picture

I've been working out how to replace the webform module by building on CCK, Views, and Actions (for emails) using a helper module to glue all the pieces together. I've had success using this to replicate a single webform-like form, and am hoping to extend upon that idea to create a module that can be configured to handle multiple CCK-enabled data collection forms.

I'm applying for a CVS account so I can share my code in a sandbox to start, and then begin pushing this idea forward.

The basic, single form module was pretty simple:
1. Use hook_form_alter() to hide the Title field and feed it an auto-value (for instance "Library card application submitted - 20070515"), since a we don't necessarily want a title filled out by the user, but we may want a title for use in our view.
2. Use hook_nodeapi() to trigger an action (email or whatever) on node submit.

Setting up a data form is easy, then. Using CCK, define the node according to the data collection needs. Then define the view and configure the action instance that we act on in number 2 above.

My code is definitely thinking small, at the moment, but I don't see why with some effort it couldn't be built out from there and make room for configuring multiple dataforms that trigger actions and are visible via views.

All the pieces are starting to come together for replacing Webform:

mlsamuelson

The "Automatic Nodetitles"

mfredrickson's picture

The "Automatic Nodetitles" module does what you form alter does. If others are trying to recreate this process, it's a good place to start:

http://drupal.org/project/auto_nodetitle

Seems to be the way of things

mgifford's picture

Interesting to see where things go with cck vs all other drupal modules. However, I'm going with the flow for the moment.

Wanted to do something similar but thought about using the computed field to do the logic of sending the mail. It works. You can stick all kinds of useful php in there to get evaluated when the node is created.
http://drupal.org/project/computed_field

Mike

OpenConcept | WLP | FVC | OX | OO

Extending Field Actions Module

mgifford's picture

We put forward an idea to extend the field actions module here:
http://drupal.org/node/148074

Didn't take off though (not a title to inspire action perhaps).

I'd actually like to be able to pull in an email from a field in another cck node type.

Is anyone working on this?

OpenConcept | WLP | FVC | OX | OO

A completely different

karens's picture

A completely different approach would be to leave email info out of the node and use Views as a mailer. See http://drupal.org/node/134931 for that idea. That would use Views to collect a group of recipients for a mass email with the idea of storing the message and using the actions module to schedule it to be mailed at some specified time in the future.

I don't know if this is better, worse, or different than Mark's proposal, just another angle.

Did anyone post any code snippets from their approaches?

mlncn's picture

Last time I sent mail myself it was Drupal 4.7 and I used the straight PHP function. Looking for what level of Drupal the people who have already thought about this thing should be used for the actual act of mailing.

Many thanks,

benjamin, Agaric Design Collective

benjamin, agaric

Believe I just used actions

mlsamuelson's picture

Believe I just used the send email action for the approach I mentioned above.

mlsamuelson

Hi would love to see a simple

summit's picture

Hi would love to see a simple solution to be able to get an email on node SUBMIT on a specific node-type?
Thanks in advance for your reply!
greetings,
Martijn

Content Construction Kit (CCK)

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week