By calebm12 on
I currently have a setup where i have sauces and recipes. The recipes node type has a node reference to sauce node type. If the site owners delete a sauce then the recipe is no longer useful as an active node and should be deleted. However i cant find a way to accomplish this. Should it be in rules?? The closest related issued i found on this forum is (http://drupal.org/node/750682) but am unsure how i would call that function??
Comments
"on delete cascade" of referred nodes
I've been attempting to do the same thing. As far as I can tell, you need to create your own custom module. I haven't had any luck getting it working quite yet however.
Check out this blog post: http://madeout.blogspot.com/2009/06/drupal-nodereference-couple-of-bonus...
agreed, custom module is the
agreed, custom module is the way to go.
d3str0y, at a quick glance, your code looks good, what issues are you having with it? have you confirmed your database names and tables?
Toronto Website Developer
Lets assume the tables in
I've ended up implementing solutions from this post, "referential integrity": http://drupal.org/node/83929
There are other interesting suggestions here: http://groups.drupal.org/node/155384
such as:
Views Bulk Operations(VBO) + Rules
Sandbox project: http://drupal.org/sandbox/modulewallah/1136472
http://drupal.org/project/cck_referential_integrity (will not delete nodes but instead sets them to NULL)
The hook_nodeapi code will
The hook_nodeapi code will fail in case user deleting the referred node [e.g. Article] doesn't have delete access on referring node [e.g. Article Review] as node_delete function first checks for node_access('delete', $node);
The other solution is to set referring node's referred nid field [e.g. content_type_journax_response] to NULL as below on delete:
Then further using hook_cron, delete all the referring nodes [Reviews] having referred nid [Article NID] as NULL.
Best Regards,
Tajinder Singh Namdhari
https://TajinderSinghNamdhari.com
look at https://drupal.org/project/crossclone
https://drupal.org/project/crossclone does some of this, having settings to delete 'downstream' or 'upstream' dependencies.