Closed (fixed)
Project:
Simplenews
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
13 Oct 2007 at 00:27 UTC
Updated:
23 Feb 2011 at 19:30 UTC
Jump to comment: Most recent file
Comments
Comment #1
sutharsan commentedThis could be achieved with an integration of Token module with simplenews. Patches are welcome.
Comment #2
sutharsan commentedDuplicate request: #364408: Token integration
Comment #3
sutharsan commentedI had this half finished simplenews.token.inc module in my sandbox. Perhaps someone wants to take if further. Using the recently added function simplenews_mail_tokens() it should not be too hard.
Comment #4
TBarregren commentedI would also suggest that the Token module is used instead of the SImlenews specific tokens
%site,%uri,%uri_brief,%mymail,%date,%login_uri.Comment #5
sutharsan commentedI couldn't agree with you more.
Comment #6
sutharsan commentedDuplicated by: #400936: Utilize Tokens
Comment #7
sutharsan commentedChanging version to HEAD. That's were the action is ;)
Comment #8
sutharsan commentedDuplicated by #87071: Personalizing newsletters. Contains D5 patches.
Comment #9
Jean-Philippe Fleury commentedsubscribing
Comment #10
kenorb commentedIf somebody want quick custom variables, you can add your own function in:
Then you can use your own function:
Comment #11
haus commentedI am very interested in your solution for personalization of newsletters.
Could you tell where to put your functions and how to use them with simplenews, please.
Thanks
Comment #12
Pboenisch commentedIm new on Drupal.org but i am interested in changing the simplenews_mail_tokens into tokens from the token module like Sutharsan wrote in his third post.
In the next days i write how the development is going on.
Comment #14
eikes commentedApplying this patch allows you to use !recipient_name in your mail or template.
If the mail is sent out to an anonymous subscriber the email is inserted instead.
Comment #15
sutharsan commented@Pboenisch: any progress on your development?
@Eikaa: this is perhaps a nice intermediate solution, but implementing Token module is not about adding an individual place holder. Token gives much, much more options that just recipent name.
Comment #16
Pboenisch commented@Sutharsan: It is in work. I am still making the last tests with the tokens. At the moment it looks well and i think i can upload it in a few days
Comment #17
kenorb commentedYou can use mail_alter hook for define some custom tokens:
Example:
Comment #18
IWasBornToWin commented@Pboenisch I would love to test your new token code when you're finished.
Comment #19
kenorb commentedSimpler solution:
Define this hook to replace all tokens available in body mail.
Eventually you can add some condition if Token module is enabled.
Comment #20
Jackinloadup commentedsubscribing
Comment #21
Pboenisch commentedHi there
i'm sorry that you must wait so long for this patch. I didn't had the time for this because i wrote my bachelor thesis.
Here is my patch for the simplenews 6.x-1.0-rc6. I removed the simplenews_mail_tokens function and added the well-known token_list and token_values functions.
Please test it and give me feedback.
Comment #22
johngriffin commentedI would love to test this out but it fails against current HEAD, can you re-roll please?
In the meantime I'll apply it to an earlier revision and check it out.
Thanks,
John
Comment #23
johngriffin commentedPatched the failed hunks manually and it all seems to be working. I'm also adding my own tokens to insert a content listing view based upon the user's profile preferences. Fantastic, thanks for this!
Comment #24
sutharsan commentedThis is a patch for current HEAD for those who also want to test and report their results.
Comment #25
sutharsan commentedI had a better look at Phoebisch's patch. It failed and I had to completely overhaul the code. A new patch (for HEAD) for review is attached.
Comment #26
kwinters commentedThis is probably not needed... It should be fine to make it an "optional dependency" just like with mailmime.
I can't tell if it would work with this patch or not, but I'm definitely going to need access to $user->profile_company, etc. (ability to pull in user profile fields and map them to a token usable in the send, even if it requires a hook in a custom module).
Nothing else jumps out at me, I'll have to see how it works in practice.
Comment #27
sutharsan commentedTokens are also used for the confirmation emails. This makes token a requirement. To use this part without tokens would mean that simplenews requires two systems of token replacement. Token is used in 50% of the drupal 6 installations and is the third most used module. I don't see a real problem in making simplenews dependent on token.
Comment #28
miro_dietikerI've checked the patch and found two issues:
1. All tokens where displayed in admin for mail replacement. Added token_help specifier. I home this is correct behaviour.
2. Footer .tpl.php tokenized update was missing.
3. Removed unused obsolete email_token_help in .admin
Everything else unchanged.
In general i think it works pretty well, although i've found a bunch of small errors to fix outside of the scope of this issue.
Comment #29
sutharsan commentedThanks for your review. I leave the issue open for a little longer to get another review but for me the last patch is already RTBC worthy.
Comment #30
miro_dietikerSetting to RTBC. Checked another couple of minutes and reproducing code and especially checking static caching not to cache things that shouldn't be cached...
Seems perfectly right. Cool patch, Sutharsan!
Next step in evolution is:
#581500: Conditional personalisation and dynamic (uncacheable) filters
Comment #31
miro_dietikerWe need a note for users who upgrade to make clear they need to rewrite their mailings.
If not they will result having broken obsolete replacement patterns inside mails.
Comment #32
sutharsan commentedI've added a replace function for the confirmation messages and a user message.
Attached patch is committed to HEAD. Thanks to all for encouragement, code and test.
Comment #33
miro_dietikerVery nice! Thanks a lot.
Comment #35
gantenx commentedHi, I have created simplenews_token module to integrate simplenews and token module. I developed it for drupal 6. What do you think?
Comment #36
sutharsan commentedI'd rather combine efforts for this function. Please check-out simplenews HEAD, review and supply patches for it.
Comment #37
chinaKat commentedHi -- thanks for the module. Call me a newbie loser but I haven't quite nailed patch installation, so I was struggling with this. Having a module was great, I could use it right away. But, I don't know if it does what I need.
Problem: I used the global tokens listed at /admin/store/help/tokens in my newsletter, and they mostly worked great. However, the [user-name] token gives the name of the currently logged in user, which is no help to me in a newsletter because all the newsletters wind up being addressed to "admin" or "bob" or whoever creates the newsletter.
Is there a token available to get the user name of the user receiving the email?
Thanks!
ETA --
aha, I see that there is a drop down menu in the newsletter edit screen titled "replacement patterns" with the user tokens. [user] works perfectly.
Thank you for making this available, I appreciate it!
Comment #38
UNarmed commentedJust installed the module, realy hope it done the trick =] thanks!
Comment #39
roball commentedThe module posted at #35 is not needed with simplenews 6.x-2.x-dev (thanks for contributing, gantenx anyway!) since it has token support in core. Some could use
"Dear [simplenews-receiver-name]"
on top of the body. This resolves into the username of the recipient if she is registered on the site. If not (anonymous subscription), the sent mail will read
"Dear Anonymous"
which is not really useful. If a subsriber is anonymous, [simplenews-receiver-name] should resolve into a configurable string (something like "subscriber"). How could this be done?
Comment #40
sutharsan commentedRoball, Token does not support conditional token replacement. You need to write a module for this or give 'anonymous' a new name (site wide).
Comment #41
roball commentedSo I have created the issue #660496: Setting [simplenews-receiver-name] token's value for anonymous subscriber for trying to find a solution for that.
Comment #42
dsms commentedsubscribe
Comment #43
ShadowMonster commentedsubscribe
Comment #44
Matthi2 commentedThank you very much!
It works fine with the username!