Tokens, Variables and triggered email actions

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

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

Hazlitt's picture

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

jamestombs's picture

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

Hazlitt's picture

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...

stevepurkiss's picture

...you did select "Send tokenized email" as opposed to "Send email"...

I don't see those options

Hazlitt's picture

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 ;)

stevepurkiss's picture

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

Hazlitt's picture

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!

Hazlitt's picture

Ok without too much jabber here is how I solved this problem: -

  • Deleted recommended stable token module
  • Installed the latest dev version of the token module
  • disabled module token actions
  • put the site in maintenance mode
  • re-ran update.php

And bingo, the 'token replacement patterns' option now appears when creating a send email action under rules - triggered rules.

Works perfectly now :)

Brighton

Group categories

Group notifications

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