Great module!!! I mean it. It has enabled me to finally take on a certain project.

That said, I have tons of trouble with duplicates. My issue. When I have a node reference Say Node A, referenced by many Node B's and I need my primary view to be focused on Node A, but also needing info from Node B, I set up a relationship with node referrer using field on Node B, that references A.

Automatically my node:title field for Node A gets duplicates because Node A has many node references.

What is great is being able to list in Column A the Node:title of Node A and in column B, list Field:Node Reference field_on_B_that_links_to_A. This brings up a very nice list off all (if any) Node B's that reference Node A. Node is not duplicated.

The problem is, what if I want to access more information on Node B? If I create a relationship, I once again have duplicate Node A's.

My short term solution is to pull the fields in Node B into the title using Automatic Node Title. This is a shabby fix.

I would LOVE to see the ability to display the nodes as they are with the Node Referrrer field, BUT do it using Relationship so I can have views that include the entire node Hierarchy without duplicates. This would basically make the entire Node reference problems in views go away.

POST SCRIPT: The primary problem is that we can't start at the bottom (the referring nodes) and expect to get all the information. The reason is that some Node A's are not referenced by Node B's. If we start at the bottom and use the node reference fields, we get a list that misses some Node A's.
In addition, when making many to one relationships, it's just easier to make the Many nodes the referrers so we don't have to mess around or worry with Multiple Value Fields, something we have to do if the many to one relationship is managed by a single node referring to many other nodes. So, the best practice, IMO is to have many to one relationships in drupal managed with an excellent "nodereferrer" Module. Thus you work is so important! Keep up the strong work.

Comments

eric at nrd’s picture

Version: 6.x-1.0-beta2 » 6.x-1.0-rc1

I had a problem similar to yours -- getting duplicates in the referring nodes list (but otherwise working fine). Unfortunately, turning on "Distinct" in my View settings resulted in nodes getting removed that were not actually duplicates. Since the view worked fine otherwise, I implemented hook_views_pre_render() to thin out the duplicates on my own. This might be overkill, but it worked for me.

The actual logic to look for duplicates will likely be different depending on the specifics of view being examined (e.g. I was looking for duplicates in $view->result[i]->node_node_nid but that may not always be the best option), but here is what my hook implementation looked like:


/**                                                                                                                                
* Implement hook_views_pre_render                                                                                                  
*/
function MYMODULENAME_views_pre_render(&$view) {
  if ($view->name=='my_view_name') {
    // This array will store node nid values we've seen so far.                                                         
    $seen_nids = array();
    foreach($view->result as $rid => $item) {
      if (isset($seen_nids[$item->node_node_nid])) {
        // We have seen this nid already, remove the item.                                                                         
        unset($view->result[$rid]);
      } else {
       	// We have not seen this nid, store it in the seen nid list.         
        $seen_nids[$item->node_node_nid] = True;
      }
    }
  }
}
strellman’s picture

Eric I tried this but it only produced 1 node.
So I am also looking for a solution to duplicates created by node referral relationships.
And I agree it is a great module.