Posted by bartl on June 29, 2011 at 10:18am
I have a rule to send mail to subscribers, when a node is published. However, that rule gets triggered whenever the node is updated, and published, but that does not necessarily mean that the node is newly published.
So... Can I add the condition "when the node is published but only if it was not published before"?
Also, is there a way to find out that certain content fields have a new value?
BTW I'm using Drupal 7 (and thus, Rules 2).
Comments
.
You have both Unchanged node and Updated node to compare.
So you can add 2 conditions to check unchanged node's field_foo against updated node's field_foo.
Thanks, I got it to work,
Thanks, I got it to work, thanks to your suggestion.
I did have a bit of a problem, though: because new content doesn't have a "node-unchanged" parameter, I had to separate the single rule that triggered on both events (new content and updated content) with several actions, into 2 rules, so I had to convert it into a ruleset...
For the other people who might have the same problem, here's how I did it.
The way I did it was to export the existing rule, and copy its JSON into a text editor; and also create a dummy ruleset (with just one simple rule), and export that too.
Then I copied just the
"DO": [... ]part from the export of the rule, and replaced the ditto part in the export of the ruleset.Finally, I went to "import component", and pasted the lot into the textarea.
.
You mean there is no "unchanged content" when firing a triggered rule ? I think there is no need to use a ruleset though.
If I have understood this correctly...
then this snippet will let you use one rule for both new and changed content and thus have one rule trigger on the two events, rather than two separate rules:
Just check for the existence of the $node_unchanged variable itself.
if (!isset($node_unchanged)){
Do stuff associated with new content here.
} else {
Do stuff associated with changed content here.
}
Hope this helps, even if months late (only just started with D7 myself).
Ed
and without php code...
I found how to make it with views 3.7 and rules 2.5 :
make an new event react on "every time a content is updated"
Then, on the conditions :
add a first compare condition on [node-unchanged:status] with value "not published"
add a "and" operator
add a second compare condition (nested in the and operator) on [node:status] with value "published"
Then you can change the value of [node:created] with [node:changed]