I want to use the node create action, but, it creates nodes even if the node already exists. Seems to me that is probably not the right behaviour?

Here is a trivial 3 line patch:

Index: node.rules.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/rules/rules/modules/Attic/node.rules.inc,v
retrieving revision 1.1.2.39
diff -r1.1.2.39 node.rules.inc
286,292c286,296
< $node = (object)array('type' => $settings['type']);
< node_object_prepare($node);
<
< $node->name = $author->name;
< $node->uid = $author->uid;
< $node->type = $settings['type'];
< $node->title = $title;
---
> $node=node_load(array("title"=>$title));
> if (! $node) {
> $node = (object)array('type' => $settings['type']);
> node_object_prepare($node);
>
> $node->name = $author->name;
> $node->uid = $author->uid;
> $node->type = $settings['type'];
> $node->title = $title;
> }
>

Comments

amitaibu’s picture

Component: Rules Core » Rules Engine
Category: feature » support
Status: Needs review » Closed (won't fix)

No one said you can't have nodes with the same title. If you want to check that, you can have a condition "PHP exceute" and there :

return !node_load(array("title"=>$title));
ChaosD’s picture

Status: Closed (won't fix) » Needs review

can your code be modified so it only checks titles in one content type?
i.e. i have type A and B ; Node "Coolnode" is content type A
now i want my rule to create a new "Coolnode" in B, after checking if there is already a "Coolnode" in B only. it can have the same title as the node in A but should be unique in B

fago’s picture

Status: Needs review » Active

There is no patch to be reviewed, so please don't set this status.

mitchell’s picture

Status: Active » Fixed

can your code be modified so it only checks titles in one content type?

Just add second condition of 'content has type.'

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.