Download & Extend

views: display parent if no child

Project:Node Relativity
Version:6.x-1.2
Component:Documentation
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

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

#1

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!):

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

#2

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

#3

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.