By arvinsingla on
I have two node types, 'Game' and 'Review'. Review has a node reference to a Game. I want to generate a list of games which currently DO NOT have reviews associated with them. It's very easy to list the games that have reviews, but I'm tearing my hair out trying to get it the other way around.
I've also given the dev version of Node Referrer a whirl using the relationships but no go. The SQL behind the query is quite simple, but no real way to get views to generate that query.
Any advice would be greatly appreciated.
Comments
Did you find a way to do
Did you find a way to do this? I'm stuck with the same requirement as well!
I'm trying to have this
I'm trying to have this solved as well, #427072: Using NodeReferrer to show nodes that are NOT being referenced
I'm also having this
I'm also having this problem
http://drupal.org/node/460272
sql created by views2
sql i want
(Note just the IS NULL instead of ='0')
if I could do a default argument of "IS NULL", then it would return nodes that are not referenced. I guess I should open a feature request for views?
Under views2, there is an
Under views2, there is an option for you to add "Relationships".
Just add the nodereference field for your Review in there and check "Require this relationship".
That would help if i wanted
That would help if i wanted nodes that had a reference. however, I want nodes which don't. see my sql above. I want to choose when the node reference IS NULL (there wasnt a match with the left join)
Well... I can think of a
Well... I can think of a workaround if you want..
You'll need to have the Rules module installed in your site to get it to work..
Using the Game and Review example.. here's what you can do.
- Add a new CCK select list to Game called "Has review" and give it values "Yes" and "No". Then set the default value to "No".
- Then add a new triggered rule that is triggered when a new Review is added. Check if the field "Has review" in the referenced Game has been set to "Yes". If not, add the action to set the field to "Yes".
- Create a view that only retrieves the Games that has its field "Has review" set to "No"
That should be able to do...
I have now implemented this
I have now implemented this by hacking the view SQL (as a custom module)
ugly but it works.
is this really the only way
is this really the only way to do this?
I basically applied a rough
I basically applied a rough hack too. very simply. I mearly created a triggered action that happens when I save the node that references another. The action loads the referenced node and populates a field in the referenced node that is hidden. I then use this field as a flag. Then list all nodes NOT flagged (ie field value NULL.)
I just add this if: <?php if
I just add this if:
if ($view->args[0] != 'all' || $fields['field_proyecto_relacionado_nid']->content == '-1' ) :to the fields template. If its "all" and the nid is -1 (I configured this '-1' from views) then is will show up only the ones whe doesn't have any node related
Can you elaborate?
What do you mean by 'fields template'? Where does this code go?