Would it be that hard to add some personalization variables to the newsletter?
As well as making the newsletters nicer, it would help them get delivered, since many of the junk mail filters (such as spamassassin) give points against email messages that have no personal greetings line.
At the moment we have: %site (the name of your website), %uri (a link to your homepage), %uri_brief (homepage link without the http://), %mymail (your e-mail address), %date (today's date), %login_uri (link to login page).
What I would like to see is:
1. a variable %user which defaults to a value of "subscriber" if the subscriber doesn't have an account.
2. a variable %profile_xxxx which pulls a value from the user's profile, from field xxxx
-there would have to be some way of defining a default for this in the syntax if there is no content to this field or if the subscriber doesn't have an account.
If someone would point me in the right direction, I would have a go at doing this.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | simplenews.module.patch | 4.86 KB | WeAreGeek |
| #8 | simplenews.module_6.patch | 6.71 KB | sgdev |
| #7 | simplenews.personalizing.patch | 3.4 KB | Petra |
| #3 | simplenews.module_5.patch | 5.21 KB | sun |
Comments
Comment #1
AlanT commented+1 on this. A few more variables shouldn't conflict with the 'simpleness' of the module, and will make the communication that much more effective.
Comment #2
sunComment #3
sunI needed this functionality for an accounting system we're developing on Drupal.
The attached patch basically allows to insert user profile fields into newsletters. However, these tokens should be used carefully as you do not know which profile fields a user has filled in and because there is no profile information for anonymous recipients (without a user account) at all. I'm currently unsure how to handle those conditions. It might be that there are only limited solutions to this issue, such as (optionally) sending a newsletter to recipients that have filled in the required fields.
Anyhow, IMHO this approach should be converted into a new hook_simplenews_fields(), so any module is able to provide additional (text replacement) fields for newsletters. F.e. you can think of amount of unread private messages, time since last login, birthday reminders, etc.
Comment #4
Tobias Maier commentedwhat about utilizing the token module instead of reinventing the wheel?
read more about its features at http://drupal.org/project/token
Comment #5
andrewfn commentedExcellent idea! +1 from me.
Comment #6
sunToken module currently does not support profile fields. However, smk-ka is already working on this implementation over here.
Comment #7
Petra commentedI'm also interested in personalizing newsletters. Make profile fields available is a good idea. But I only need 'username' to write "Hello username" in a newletter, so I used user-token to get this.
[reg-since] and [log-since] only show years and weeks, so I didn't insert them in the description.
To get the send-variable in simplenews_view() I used $_POST, because it was the only way I found.
I inserted token_replace() in simplenews_mail_send(), as in simplenews.module_5.patch - perhaps there is a better place.
Can anybody have a look at the code. I don't know how to make it better.
Comment #8
sgdev commentedI implemented the Token module patch for profiles, but it did not seem to fully meet my needs.
Then I tried the above patches in #3 and #7 together to cover all conditions. These definitely seem to work.
What's the possibility of getting #3 and #7 rolled into the next version of Simplenews, or are there other plans for Token which will meet these needs? If it makes sense to get them into Simplenews, I've created an updated patch. It is attached and has been tested with 5.x-1.5.
Comment #9
WeAreGeek commentedHi,
All of the above patches failed to apply to the current stable release.
With the patches from #3 and #7 one hunk failed.
The patch in #8 didn't work at all, because it was malformed.
Please look into this again.
In the meantime I'll try and check what went wrong. If it works, I'll post a new diff.
Raoul
[edit] Patched it (#8) manually, against 5.x-1.5, tested, and it seems to work. Please see the Diff attached and review. Thanks.[/edit]
[edit 2] Actually, the profile fields don't work, whether I'm using the @profile_name or %profile_name variable. The tokens work perfectly though. I need to review my patch.[/edit]
Comment #10
sgdev commentedPatching manually using #8 should work with no problem, including the profile options. I've got it running on a live production site right now.
Comment #11
callison commentedAlso see http://drupal.org/node/127178 for similar request.
Comment #12
sutharsan commented@callison: This issue is about token integration, i.e. using personal data not about collecting it.
Comment #13
Jean-Philippe Fleury commentedSubscribing
Comment #14
sutharsan commentedDuplicate of #183120: Support Token module. Changing version to HEAD.
Where possible code of these patches will be used for HEAD.
Comment #15
kenorb commentedSome quick solution here: http://drupal.org/node/183120#comment-1398060
Comment #16
claudiu.cristeaTry Views Send. It allows personalization and full recipient list filtering based on Views.