Closed (won't fix)
Project:
Node Hierarchy
Version:
6.x-1.x-dev
Component:
Drupal/PHP Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
30 Nov 2008 at 16:58 UTC
Updated:
9 Apr 2011 at 01:56 UTC
Is there a way of strictly enforcing the parent-child relationship?
I have two node types: A (can be parent) and B (can be child). Here is what I need:
1) B-nodes to exist only in the context of an A-node, therefore:
1a) There should be no way of creating stand-alone B-nodes. B-nodes should be created only from the "Add child" link in the parent node.
1b) When an A-node is deleted, all child B-nodes should be deleted too (there should be a warning though)
2) Since the relationship is enforced, there is not need form the Node Hierarchy collapsed section that allows for choosing another parent.
What is the easiest way to achieve this functionality?
Comments
Comment #1
kirilius commentedHi there? I'd appreciate any comments!
Comment #2
ronan commentedHi there,
1 is on my long term todo list, but limiting parent/child relationships by type is more complex than it seems at first blush so it keeps getting put off.
A variation of 1b is closer. My latest unstable test code has the option to delete or move descendents of a node when deleting the node. That version is a pretty dramatic rewrite of the db storage mechanism (much more efficient) so it may be a while before it's stable enough for a release.
If you're comfortable writing a custom module to solve your particular needs some of what you want can be accomplished with hook_form_alter and hook_nodehierarchyapi. Let me know if you want more info on how to go about that.
R
Comment #3
kirilius commentedThanks for the update!
I actually don't need node type enforcement in the hierarchy. Since I have only two node types engaged in a hierarchical relationship, I don't have an issue with the types. What I need is the hierarchy enforced on node level, not on node type level. If I configured that B-type can be a child and I don't have other node types that can be children, I am OK. What I need though is when a B-node is created, the parent field to be mandatory, i.e. I shouldn't be able to create a B-node without specifying a parent.
I played a bit with the CCK nodereference and it actually can help to a certain degree in my case. If I add a nodereference field to my B-type that references my A-type and make that field mandatory, my requirement (1a) is fulfilled. Then I can create views using that field as argument. What is still missing though is the (1b) functionality that deletes the children when a parent is deleted.
Another thing that is missing in this case is the nice child order and links operations view field that you have in node hierarchy.
Comment #4
markhalliwellCopy & Pasted: This issue pertains to the 6.x-1.x branch which is now legacy and is over two years old. If this issue is not applicable anymore, please consider closing it. Otherwise, please update this issue appropriately. Will be closed in two weeks if no response.
Comment #5
kirilius commented