views:

189

answers:

1

I would like to find all nodes of type A which don't have a child of type B matching a certain condition. For example, imagine I have a department node and an employee node. A department has an employees field which lists all the employees. Each employee has a type, let's say manager or peon. I would like to find all departments that have no manager. Is there any way to do that with views in drupal? I can do the opposite, find all departments which do have a manager, but the reverse seems impossible to do given the Drupal view ops (Relationships and Filters).

+1  A: 

Clarifying your data model is the first necessary thing, it's difficult to answer the question without that. I gather you are not using OG, so you are using Nodereference to specify "children" and Taxonomy or a Text Field to label "types"?

Have you tried creating a Relationship on your Nodereference, then a filter on the referenced node's taxonomy/text field specifying NOT X?

Grayside
I don't know what OG is. In a department node, I'm using a "Node Reference" field type (unlimited number of values) to list the employees. Employee type is currently a text field of Employee, but I'm open to anything that might work. In the future I'd like to do more complicated filters, like "list departments with no employees making more than X$/year".Your suggestion won't work because it will select departments which have both managers and peons.
Keith Randall

related questions