Is it possible to do the Views query on a specific node reference field (i.e. the results will come from the referenced nodes) - Same as ReferencedByFilter for D5.

Comments

merlinofchaos’s picture

Yes, add a relationship on that node reference; add all your fields for the referenced node and add your argument on the basic node.

ratnesh aarohi’s picture

I think my need is similar - i have one cck with book name, book author, Book number, book publisher, book references etc (some more fields);
Next i have another cck called bookreading_schedule with two fields - one date and another (a node reference) to the above book name.
Now I want a view (based on node: 'bookreading_schedule') with date, book name, book author and book number (only these four fields)
How do i do this
1. how do i set the relationship to the node reference
2. how do i get only the selected fields from the referred node to show up in views in tabular form
thanks
ratnesh

amitaibu’s picture

@merlinofchaos,
Thanks for the quick reply - I've added documentation about it: http://drupal.org/node/289738

ff1’s picture

Status: Active » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

tiago.gmarques’s picture

Status: Closed (fixed) » Active

What if I want it the other way around?
With this I mean that I want to view the nodes that reference a certain node on that node display.

For example:
Node type - Artist;
Node type - Song (with a node reference field for the Artist);
View of Songs by a certain Artist on that Artist node.

Is this possible?

jeremy_a’s picture

slider:

Argument: node reference (Artist)
Fields: Node title, etc
Filter: node type: Song

Cheers

tiago.gmarques’s picture

Really? I had already tried it and wasn't able to do it.

I am displaying the view in a block and inserting it in a panel in the node.

In the arguments option, when I select the node reference if I choose 'Display empty text' in 'Action to take if the argument is not present', I get no views all the times. However if I choose 'Display all values' I get all the Song typed nodes. So it's as if the Argument is not working at all... What could I possibly have done wrong in here?

How should I configure the 'Validator options'?

Thanks for the help.

jeremy_a’s picture

Hi slider,

It sounds you need a default argument in your block. If the nid (node number) you want is argument 1 in the url (eg node/123) choose "provide default argument" and "PHP Code" and enter this:

$args = arg(1);
return $args;

For the validator, you could choose "Validate by node type" then choose "artist" so that the block returns only artist results.

tiago.gmarques’s picture

Excellent! It works flawlessly. Thank you a lot!

Just one thing, when I choose 'Provide default argument', there is one option 'Node ID from URL' that works fine, so no need to use the PHP Code.

I am going to create an entry explaining this in the documentation.

tiago.gmarques’s picture

Status: Active » Fixed
merlinofchaos’s picture

This is already explained in the documentation.

tiago.gmarques’s picture

I am not so sure...

What I found was the following tutorial (http://drupal.org/node/289738). This explains how to create a view of the nodes a certain node reference.

What I am talking about is the opposite, which I think is more useful, that is to create a view in a certain node, of the nodes that refer to that node. This I couldn't find it anywhere.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.