I love this module! I've figured out how to show children of a parent in a view, but I'm stumped on this one. How do I show all the parents without children? For instance, let's say all my parents are all "parent" content types, and my children are all "child" content types. There are a bunch of parents in my database that have children, but I want to show only the parents without children. Since it is a list of the parents I want to view, I can't figure out how to use the Node Relativity parent relationship to filter.

Comments

oda’s picture

I think that relativity does not do it out of the box :P

Since all relationships are stored in "relativity" table, you can use viewsphpfilter and add a filter like this (please, note that I didn't test it and this query has a very very bad performance!):


$nids = db_result(db_query("SELECT GROUP_CONCAT(vid) FROM node WHERE nid NOT IN (SELECT parent_nid FROM relativity)"));
return $nids;

cindyr’s picture

Sweet! It works just as you wrote it. Thanks so much!

davethedruper’s picture

Cindyr/anyone who knows,
Would you be able to explain how you set up your view to show the parent and child together in a view? I know it must not be that hard but I can't figure it out. I can get one or the other but I can't seem to display them both as I just want to display the node title of each; and I have them as two different content types. Thanks for your assistance and help.