Hello,
I use following rule to send email notification after content changes.
{ "rules_content_change" : {
"LABEL" : "Content update",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "Content change" ],
"REQUIRES" : [ "php", "rules", "taxonomy" ],
"ON" : {
"node_update--program_course_builder" : { "bundle" : "program_course_builder" },
"node_insert--program_course_builder" : { "bundle" : "program_course_builder" },
"node_update--city_page" : { "bundle" : "city_page" },
"node_delete--city_page" : { "bundle" : "city_page" },
"node_insert--city_page" : { "bundle" : "city_page" },
"node_delete--program_course_builder" : { "bundle" : "program_course_builder" },
"node_update--page" : { "bundle" : "page" },
"node_delete--page" : { "bundle" : "page" },
"node_insert--page" : { "bundle" : "page" },
"node_update--job" : { "bundle" : "job" },
"node_insert--job" : { "bundle" : "job" },
"node_delete--job" : { "bundle" : "job" },
"node_update--news_page" : { "bundle" : "news_page" },
"node_insert--news_page" : { "bundle" : "news_page" },
"node_delete--news_page" : { "bundle" : "news_page" },
"node_insert--testimonials" : { "bundle" : "testimonials" },
"node_update--testimonials" : { "bundle" : "testimonials" },
"node_delete--testimonials" : { "bundle" : "testimonials" },
"taxonomy_term_delete--location" : { "bundle" : "location" },
"taxonomy_term_insert--location" : { "bundle" : "location" },
"taxonomy_term_update--location" : { "bundle" : "location" },
"taxonomy_term_delete--program_course_type" : { "bundle" : "program_course_type" },
"taxonomy_term_insert--program_course_type" : { "bundle" : "program_course_type" },
"taxonomy_term_update--program_course_type" : { "bundle" : "program_course_type" },
"taxonomy_term_delete--course_level" : { "bundle" : "course_level" },
"taxonomy_term_insert--course_level" : { "bundle" : "course_level" },
"taxonomy_term_update--course_level" : { "bundle" : "course_level" },
"taxonomy_term_delete--language" : { "bundle" : "language" },
"taxonomy_term_insert--language" : { "bundle" : "language" },
"taxonomy_term_update--language" : { "bundle" : "language" },
"taxonomy_term_delete--course_category" : { "bundle" : "course_category" },
"taxonomy_term_insert--course_category" : { "bundle" : "course_category" },
"taxonomy_term_update--course_category" : { "bundle" : "course_category" },
"taxonomy_term_delete--translation" : { "bundle" : "translation" },
"taxonomy_term_insert--translation" : { "bundle" : "translation" },
"taxonomy_term_update--translation" : { "bundle" : "translation" }
},
"DO" : [
{ "mail_to_users_of_role" : {
"roles" : { "value" : { "7" : "7" } },
"subject" : "content has been changed. Please change contents in your related site.",
"message" : "Following page has been changed.\r\n\r\nRevision log message:[node:log]\t \r\n\r\nChange time: [node:changed]\r\nChanged by:[node:author]\r\nNew Added: [node:is-new]\r\n\r\nType:[node-unchanged:content-type] \r\nPage Title:[node:title]\r\n\r\nGo link: [node:url]\r\n\r\nClick Revisions Tab -\u003E then click Compare button to see the differences -\u003E click \u0022Marked down\u0022 link button to view clearly\r\n\r\n\u003C?php\r\n$termid = arg(2);\r\n$term = taxonomy_term_load($termid);\r\n$title = $term-\u003Ename;\r\necho $title\r\n?\u003E\r\n ",
"from" : [ "" ]
}
}
]
}
}
All content types e.g. basic pages work well.
But for "taxonomy_term_delete--translation"
"taxonomy_term_insert--translation" :
"taxonomy_term_update--translation" :
I get the empty message, all tokens - [node:changed] [node:author] [node:is-new] :[node-unchanged:content-type] [node:title] are not being replaced with values.
How do I get the tokens to display the value? I have the following installed:
Drupal 7 version: 7.38
Rules (rules)Version: 7.x-2.9
Token (token): Version: 7.x-1.6
Entity tokens (entity_token):Version: 7.x-1.6
Comments
Comment #1
cam_pdx commentedAbove when I mentioned "importing this rule", I was referring to this one from the documentation: http://drupal.org/node/298517
Comment #2
dwils03 commentedI am having the same problem. In my case, I'm trying to send an email to a user. The rule executes fine, but the text of my email still has all of my tokens in it, without the replacements:
"Hi [node_author:user]!
[comment_author:user] just posted a comment on the [node:type-name] that you
posted on [node:d] [node:month].
Check it out here:
[comment:site-url]/node/[node:nid]#comments"
(I have copied the text of the tokens from my Drupal 5 site.) When using Workflow-ng and token in Drupal 5, I had a list of Replacement Items show up on the rule configuration page. I don't even see that list, even with token and token actions enabled in the modules list.
A resolution to this problem would be much apprecitated. Thanks in advance!
I'm using the following:
Drupal 6.10
Rules 6.x-1.0-beta5
Token 6.x-1.11
Comment #3
cam_pdx commenteddwils03,
I finally got this working. What I did was to try to match module for module between a fresh sandbox site and my main site (I was thinking that some module combination was the cause). After getting Rules versions matching, tokens were still breaking. Then I tried editing the affected rule and re-saving. After that, it worked. Perhaps you should try that.
Rules 6.x-1.0-beta5
Workflow 6.x-1.1
Token 6.x-1.x-dev
Comment #4
fagoToken 6.x-1.11 -> you need a more recent version. Read the installation instructions.
Comment #5
Anonymous (not verified) commentedHave the same problem here. Inserting nodeID data with PHP working as expected but no replacement when using tokens.
Drupal 6.10
Rules 6.x-1.0-beta5
Token 6.x-1.11
=======
Sorry just re-read the thread and now have it working by using the dev version of Token.
This seems to be a recurring problem. I realise that there is a note on the Rules front page that says "You need a snapshot which stems from >27.08.08" but this language isn't clear enough for the average user. It may perhaps help to spell it out and say that the release version of Token 6.x-1.11 will NOT work with Rules.
thanks
Comment #6
fagook, I added that.
Comment #7
gettysburger commentedI've been trying to get this to work for a while and was able to get system tokens like the name of the site to work, but not node-specific tokes.
I just upgraded to:
Token 6.x-1.x-dev (2009-Apr-20)
Rules 6.x-2.4
...and now if I do:
"[node:author-name] has published a [node:type-name] node called [node:title] at [node:node-url][node:nid]"...I get:
Joe Editor has published a Job node called Baking Chef at http://www.mycollegeedu/node/.
Seems now, at least, it grabs the content type and the node title, just not the path to the node. Closer, though.
Comment #8
ilakshmir commentedI am using token 6.x-1.x-dev and having a similar problem:
I have a rule that runs on a node update. On each update, I create another node labeled 'b' via the action 'add a node'. I then execute a php script to write into the fields of b. I can access [node:nid] in this php script but not [b:nid] although the token replacement patterns shows this token as available.
Any ideas for fixing this?
Thanks
iyer
Comment #10
westbywest commentedSubscribing.
I was having a problem with NO tokens being processed in an email launched by a rules action.
Relevant config:
Drupal core 6.12
Token 6.x-1.12
Rules 6.x-1.0
Rules Administration UI 6.x-1.0
Token Actions disabled
Then, it worked fine after I disabled the TokenSTARTER module, even tho the configuration with TokenSTARTER enabled (but presumably unused) worked fine on an identical site.
Is there an undocumented dependency or contention between TokenSTARTER and Rules? Or perhaps a race condition?
Comment #11
AlexisWilke commentedfago,
I ran in that problem too, with the Taxonomy Term. I found and fixed it. I will post my patch in another issue because it includes other additions (new features.)
I do not know whether this is the problem mentioned here, but what was happening in the Load Term is that the data was not at the bottom level in the array.
The array goes something like this:
But the evaluations will only happen on data that are defined at the first level. Thus the 'tid' and 'name' will never be changed in these settings. I'm wondering whether the token replacement should be transformed to work on any level or just all the forms fixed to work properly.
At this time, my fix is to move form data at the time it is submitted to the top level... It works for me, but we need to know which way is correct.
Thank you.
Alexis Wilke
Update: Okay. I found the solution: #472038: Fix eval input in taxonomy actions, you add the names between pipes: term|term_text in the case of the add term. Somehow, it was fixed for the vocabulary, but I did not see the fix for the term... Anyway, you can ignore this message! 8-)
Comment #12
fago@#10: no, but when you did this your cache was cleared.
@#11: yep :)
Comment #14
Anonymous (not verified) commentedDrupal 6.13 (recent upgrade)
Rules 6.x-1.0
Tokens 6.x-1.12
As per #10 I made sure TokenSTARTER was off - and tried to activate and de-activate it as well.
Cleared cache (and got heaps of error messages) http://drupal.org/node/531400#comment-1859348
Turned off Trigger in Core (and therefore disabling Simplemail) just in case.
But I am not even seeing a list of tokens that can be used when I set up, or edit existing rules in question under the "Add a new rule" to a "Rule set".
I am however seeing the replacement tokens when I "Create a new rule" (singular)
The Action for both the Rule within the Set and the new Rule singular are "Send an email to an arbitrary email address" but only the Rule singular shows tokens.
[ /admin/rules is giving me white screens too upon clicking on the breadcrumb link. ]
Any ideas. Have I missed something blindingly obvious (very late night/early morning) ?
T.I.A.
Comment #15
Anonymous (not verified) commentedPerhaps I am expecting a function that is not there?
I tried to create another rule set on another website and also found that 'Tokens' were not accessible to rules within sets.
Is there somewhere that this can be enabled?
Comment #16
jazzslider commentedHello!
I hate to re-open such an old issue, but I feel like there is a legitimate problem here; I had fixed this problem by installing the latest dev of token a few weeks back, but it resurfaced when our automatic update system accidentally restored to 1.12. On noticing this, I completely uninstalled token, reinstalled the latest dev version, and …no token replacement in emails. For reference, this is what I've got running at the moment:
Drupal 6.14
Rules 6.x-1.1
Token 6.x-1.x-dev (2009-Oct-02) [as of today…problem failed before I installed today's build, though]
Token actions disabled
Also…when I'm editing the rule, the collapsed Token Replacement Options section is definitely available. When I was running 1.11 (the first time I had to fix this problem), that part wasn't even there. So maybe this is a different issue?
I do not have tokenSTARTER enabled per #10, and I have cleared out my cache any number of times per #12. The email output from the action looks something like this:
A new node has been posted at [node:node-url] Here is a brief
summary:
[node:node-teaser]
I believe I've tried all the documented solutions…does it look like I've missed anything obvious?
Thanks!
Adam
Comment #17
fagoDoes it work elsewhere? Perhaps there is some problem with tokens related to the e-mail action, also see http://drupal.org/node/486168.
Comment #18
jazzslider commentedHello!
Seems to be a different problem; I read through the referenced case and tried the various solutions mentioned (adjusting action weights, deleting the action and re-creating it, etc.) to no avail. However, my symptoms are different: I'm receiving the mail (using the "send a mail to an arbitrary mail address" action), but the tokens are not being replaced.
As far as I can tell, other kinds of token replacement are working just fine on this site; e.g., our pathauto configuration uses tokens, and seems to be working.
I can't really see anything that should be causing this issue, especially since token replacement used to work correctly on this configuration. The only thing I can trace it back to is that when we automatically "updated" from the dev version of token to 1.12, it stopped working…but then when we restored back to the -dev version, it still wasn't working.
Comment #19
jazzslider commentedHello!
Still stuck; I actually completely uninstalled both rules and token and then reinstalled the correct versions of both…re-imported my rules, and got the same result…email correctly delivered, but no token replacement.
Looking at the exported rule code, I noticed the following entry attached to the action that's sending the mail:
I'm not totally sure what all is going on there, but it sort of seems like it's trying to produce tokenized output…do those values look correct? If not, what should I try changing them to before re-importing my rules?
Thanks!
Adam
Comment #20
garretg commentedI had the same problem with token replacement that others report above... and I found the solution (at least for my case.)
I was missing the "Content" argument for the ruleset in which I have a "Send email" action.
Rule set arguments are a bit of a mystery to me, so I don't exactly understand what's going on.
But my guess is that the rule form codebase detects whether you have content (node) data available in the parent ruleset, and if not, it hides the token replacement suggestions link, and doesn't perform token processing when the rule is executed.
For a walk-through of how a rule set with "Content" argument should be set up, follow this tutorial:
http://drupal.org/node/517674
Comment #21
bombadillo commentedEdit of my previous post.
EDIT:
Ok i discovered the way to reproduce the bug:
if i enable a rule to trigger and send a mail when an upload field is edited
it crashes if the user decides to remove a precedently uploaded file and doesn't upload anything in replace.
It's nothing about tokens but it seems a bug.
The Drupal log says:
It's really a mistery for me.
If anyone has an advice i'm here
thanks
David
Comment #22
shyam541 commentedSubscribing
Comment #23
brycesenz commentedsubscribing
Comment #24
kbk commentedFWIW, I've noticed that Raw tokens are replaced while Formatted tokens fail for the same field. In my case, I was experimenting with CCK Email and CCK Text fields.
Comment #25
mariamr commentedCheck this out http://drupal.org/node/520012
Comment #26
dbassendine commentedsubscribing
Comment #27
tmalo commentedIt might be that the data_type classes are not defined when the rule is triggered.
In mymodule.rules.inc, I put those two lines :
The replacement is now working fine.
Comment #28
wildguy commented+1 subscribing
Comment #29
cwithout commentedI had this same problem with Rules 6.x-1.5 and Token 6.x-1.17.
Upgrading Token to 6.x-1.19 solved the problem.
Comment #30
wadezhu commentedI use following rule to send email notification after content changes.
{ "rules_content_change" : {
"LABEL" : "Content update",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "Content change" ],
"REQUIRES" : [ "php", "rules", "taxonomy" ],
"ON" : {
"node_update--program_course_builder" : { "bundle" : "program_course_builder" },
"node_insert--program_course_builder" : { "bundle" : "program_course_builder" },
"node_update--city_page" : { "bundle" : "city_page" },
"node_delete--city_page" : { "bundle" : "city_page" },
"node_insert--city_page" : { "bundle" : "city_page" },
"node_delete--program_course_builder" : { "bundle" : "program_course_builder" },
"node_update--page" : { "bundle" : "page" },
"node_delete--page" : { "bundle" : "page" },
"node_insert--page" : { "bundle" : "page" },
"node_update--job" : { "bundle" : "job" },
"node_insert--job" : { "bundle" : "job" },
"node_delete--job" : { "bundle" : "job" },
"node_update--news_page" : { "bundle" : "news_page" },
"node_insert--news_page" : { "bundle" : "news_page" },
"node_delete--news_page" : { "bundle" : "news_page" },
"node_insert--testimonials" : { "bundle" : "testimonials" },
"node_update--testimonials" : { "bundle" : "testimonials" },
"node_delete--testimonials" : { "bundle" : "testimonials" },
"taxonomy_term_delete--location" : { "bundle" : "location" },
"taxonomy_term_insert--location" : { "bundle" : "location" },
"taxonomy_term_update--location" : { "bundle" : "location" },
"taxonomy_term_delete--program_course_type" : { "bundle" : "program_course_type" },
"taxonomy_term_insert--program_course_type" : { "bundle" : "program_course_type" },
"taxonomy_term_update--program_course_type" : { "bundle" : "program_course_type" },
"taxonomy_term_delete--course_level" : { "bundle" : "course_level" },
"taxonomy_term_insert--course_level" : { "bundle" : "course_level" },
"taxonomy_term_update--course_level" : { "bundle" : "course_level" },
"taxonomy_term_delete--language" : { "bundle" : "language" },
"taxonomy_term_insert--language" : { "bundle" : "language" },
"taxonomy_term_update--language" : { "bundle" : "language" },
"taxonomy_term_delete--course_category" : { "bundle" : "course_category" },
"taxonomy_term_insert--course_category" : { "bundle" : "course_category" },
"taxonomy_term_update--course_category" : { "bundle" : "course_category" },
"taxonomy_term_delete--translation" : { "bundle" : "translation" },
"taxonomy_term_insert--translation" : { "bundle" : "translation" },
"taxonomy_term_update--translation" : { "bundle" : "translation" }
},
"DO" : [
{ "mail_to_users_of_role" : {
"roles" : { "value" : { "7" : "7" } },
"subject" : "content has been changed. Please change contents in your related site.",
"message" : "Following page has been changed.\r\n\r\nRevision log message:[node:log]\t \r\n\r\nChange time: [node:changed]\r\nChanged by:[node:author]\r\nNew Added: [node:is-new]\r\n\r\nType:[node-unchanged:content-type] \r\nPage Title:[node:title]\r\n\r\nGo link: [node:url]\r\n\r\nClick Revisions Tab -\u003E then click Compare button to see the differences -\u003E click \u0022Marked down\u0022 link button to view clearly\r\n\r\n\u003C?php\r\n$termid = arg(2);\r\n$term = taxonomy_term_load($termid);\r\n$title = $term-\u003Ename;\r\necho $title\r\n?\u003E\r\n ",
"from" : [ "" ]
}
}
]
}
}
All content types e.g. basic pages work well.
But for "taxonomy_term_delete--translation"
"taxonomy_term_insert--translation" :
"taxonomy_term_update--translation" :
I get the empty message, all tokens - [node:changed] [node:author] [node:is-new] :[node-unchanged:content-type] [node:title] are not being replaced with values.
How do I get the tokens to display the value? I have the following installed:
Drupal 7 version: 7.38
Rules (rules)Version: 7.x-2.9
Token (token): Version: 7.x-1.6
Entity tokens (entity_token):Version: 7.x-1.6
Thanks,
Comment #31
wadezhu commentedComment #32
tr commentedIf you continue to have a problem with this in the current version of Rules please open a new issue.