Patch to allow tokens in emails and messages (depends on the token module).

Waldemar - November 27, 2007 - 17:20
Project:Actions
Version:5.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:reviewed & tested by the community
Description

I had to do this for my purposes and thought that people might be interested in this as well.

Thanks for the great module!

Waldemar

AttachmentSize
actions_token.patch2.95 KB

#1

clivesj - December 5, 2007 - 16:30

Thank You.
I have applied the patch and now the "replacement pattern" link is showing beautifully on the email-action page. When I click the link I get all the avaible tokens.

When I insert the tokens in the emails however, the valuas are not transmitted to the email. So:

In the email-template i put: name=[field_myname_raw]
When i receive the mail it shows: name=[field_myname_raw] iso name:John Doe

Do I have to do anything additionally to get it working?
Thanks

#2

clivesj - December 9, 2007 - 17:08

anyone to help me on this one?

b.t.w. the non-cck-fields are displayed properly

#3

clivesj - December 19, 2007 - 17:15

Anyone??

I have checked everything but the token does not get replaced by the replacement values.

Thanks

#4

clivesj - December 20, 2007 - 15:13

Sorry, my problem was self-induced. I was using cck-field that weren't used in de content-type
The patch works perfectly
Sorry for any inconvenience

#5

agaric - January 11, 2008 - 11:33
Status:needs review» reviewed & tested by the community

#6

pete-drupal - May 24, 2008 - 21:40

(Not sure where this comment belongs. It proposes a patch to token.module, but as a direct consequence of the patch actions_token.patch described in this post)

I use Drupal 5.7, workflow 5.x-1.2, actions 5.x-1.0 and token 5.x-1.11 in order to send emails on certain workflow transitions. The mail should contain the name of the new state (i.e. after transition).

The actions_token.patch described in #195773: Patch to allow tokens in emails and messages (depends on the token module). is working fine, except that on a state transition, the token [workflow-current-state-name] shows the old state instead of the new state.

The cause seems to be that the token values are determined and cached before the state transition occurs. After the transition, the token value is retrieved from the cache instead of re-determined.

A workaround consists in replacing (in token.module)

<?php
function token_replace($original, $type = 'global', $object = NULL, $leading = '[', $trailing = ']', $options = array()) {
 
$full = token_get_values($type, $object, FALSE, $options);
  return
_token_replace_tokens($original, $full->tokens, $full->values, $leading, $trailing);
}
?>

with
<?php
function token_replace($original, $type = 'global', $object = NULL, $leading = '[', $trailing = ']', $options = array()) {
 
$full = token_get_values($type, $object, TRUE, $options);
  return
_token_replace_tokens($original, $full->tokens, $full->values, $leading, $trailing);
}
?>

(token_get_values($type, $object, FALSE, $options);
is changed to token_get_values($type, $object, TRUE, $options); to disable token caching altogether - which makes it probably a less than ideal solution)

#7

SocialNicheGuru - June 10, 2008 - 16:21

subscribing

#8

guix - August 13, 2009 - 02:04

Sub, still active

 
 

Drupal is a registered trademark of Dries Buytaert.