I have a content type named A that contains a cck nodereference field that provides a reference to itself and other "grandparent" content type named B which doesn't have any reference so the hierarchy can't go further, this is the top level. The hierarchy is something like this:
- node 1 of type B (Grandparent)
- node 2 of type A (Parent) references node 1 of type B (Grandparent)
- node 3 of type A (Child) references node 2 type A (Parent)
- node 4 of type A (Grandchild) references node 3 type A (Child)
I've noticed that the current code doesn't allow to have cyclic hierarchies, so I commented these lines of code on line 327
if (in_array($parent_referenced_type, $type_names_in_lineage)) {
continue; // avoid cycles
}
and line 334
//if (!in_array($referenced_type, $type_names_in_lineage)) { // avoid cycles
now I can set the reference path to itself several times. Now, this is partially working, except for two things:
- The first select box (Grandparent) should display only nodes of type B but there doesn't seem to be any way right now to filter the displayed values on the first row
- Second, when selecting the Parent, the Grandparent reference disappears and the Parent Reference becomes the Grandparent, this isn't like the behavior I expected.
I would like to contribute but I need some guidance or someone who points me somewhere to start in order to solve these couple of issues
Thanks
Comments
Comment #1
jrao commentedThe reason I disabled cycles is because allowing them would make implementation of HS API hook_hierarchical_select_children difficult or impossible. This function needs to take a parent node, and a node referencepath, and return a list of child nodes, the first step is to determine where the parent node resides in the node reference path. current implementation uses the fact that type+field is unique in the node reference path to achieve this step, so if you allow cycles then the code would only use the first occurrence in node reference path, which is probably the cause of your problem #2.
Comment #2
jrao commentedComment #3
off commentedSubscribe
Comment #4
sinasalek commentedsubscribed
Comment #5
tadeusz.zimirski commented+1
Could definitely use such a feature.