Posted by Hazlitt on May 27, 2009 at 1:59pm
I have spent the last two hours searching for answers on these questions and cannot find anything that provides what I need. I setup a triggered rule that sends an email when a new node type is created. This works great, but I cannot get the email to provide any node variables. I tried using tokens and still the email is sent out with for example [url] printed in the email as opposed to the url of the node.
I am using Drupal 6.12
How do I know what node tokens or variables are available to reference? I cannot find a list anywhere.
How do I get the variables/tokens to work in an email?
I even tried this in the email body: -
<?php
echo $node->url;
?>All that arrives in the email is "[url]"
TIA
Hazlitt

Comments
Update
I found a list of tokens, I still can't get the [url] token to be translated in the email sent.
I assume you have the Token
I assume you have the Token module installed?
You could try removing it and reinstalling it and seeing if it helps. If it is installed you will get the list of replaceable tokens below the textfield.
Also make sure the textarea isn't using a WYSIWYG as some editors such as FCKEditor makes most text areas in to a WYSIWYG.
James Tombs
Hi James, thanks for
Hi James, thanks for posting.
Yeah the tokens module is there and activated. I tried removing it and reinstalling it earlier on. Steve suggested trying the latest dev version which I have just installed and tested too. The tokens aren't processsed when the email is sent.
I have the following tokens listed in the email body and they appear exactly as shown in the resulting email: -
[url]
[nid]
[type]
[title]
[node:url]
The textarea isn't using an editor, I haven't got any editor modules installed at the moment.
Just checkin...
...you did select "Send tokenized email" as opposed to "Send email"...
I don't see those options
I don't see those options when I go to select an action under triggered rules, I see the following...
I read about 'tokenized email' on the forum but can't find it on that menu.
I'm too nice ;)
OK, I've had a play and worked out which tokens work (by basically copying the whole token list and seeing what gets output):
Go to admin/settings/actions/manage
Select "Send tokenized e-mail..." & click 'create'
Enter your email for recipient field.
Enter "New content on [site-url]: [title]" for the subject
Enter "URL: [site-url]/node/[nid]" for the message
Click save then go to /admin/build/trigger/node
Assign the "Send tokenized e-mail" action you just created to the trigger: After saving new post.
I'm not entirely sure why half of the tokens don't work - perhaps they've placed the token code before the creating URL code...
Thanks for your help
Thanks for your help Steve.
I have to use the rules module to trigger sending an email because it must only happen when new content is saved with a CCK field set to a specific value.
This works fine. But the tokens in the email body are not translated. Too many more hours of fiddling and reading later, it seems that there is a bug in the token module which stops them being translated in rules module triggered actions. A new dev version of the token module was made available today, I tried it and it still doesn't work.
Thanks for your replies Steve and James. It has been a rather frustrating couple of days with no result.
References :
http://drupal.org/node/432518 - others with the same problem
http://drupal.org/node/424428 - latest dev version supposed to solve the problem but unfortunately doesn't
Finally solved it!
Ok without too much jabber here is how I solved this problem: -
And bingo, the 'token replacement patterns' option now appears when creating a send email action under rules - triggered rules.
Works perfectly now :)