I have two content types : Content Type A and Content Type B. Content Type B includes an entity reference field to Content Type A. So that when creating new Content Type B, the user can use a drop down and select which Content Type A node should be referenced.

Content Type A has, among others, an image field - one image per node.

I have a View created to display information from Content Type B. I would like to also display the image from the referenced Content Type A node.

How can I do this?

Thanks

Comments

sonar_un’s picture

You know, I was working on nearly the exact same thing today. I can make the reference handling work the other way, but I can't pull fields from a referenced node, or at least. I haven't been able to figure out the reverse reference.

Subscribing.

drupalreggie’s picture

I could do this in D6 using Node Reference but can't yet figure a way in D7, would be useful!

bpeicher’s picture

If you haven't figured this out yet, here's how to do it:

On the view for Node A, create a relationship for Content entity referenced from field_whatever_your_referenced_entity_field_is_called. You don't need to require the relationship.

In the same view, add a new field for the content you want to pull from Node B - Content:Image, for example. In the field configuration window there should be a relationship option at the top where you can select the relationship you just created. This is instructing the view to display that field using information from Node B.

Apply the window and you should be done!

steven jones’s picture

Status: Active » Fixed

The answer is #3 is exactly how you'd do this.

sunchaser’s picture

for some reason or the other #3 displays ALL nodes of type B on a nodepage of type A, not just the ones that actually belong to A (and if I check the box that says "require this relationship" , I get no results at all)

haggan’s picture

I have the same setup sort of. But another problem
My view is working perfect for administrator but not for a regular logged in user.

For administrator it shows both the content A and the content B that is referring to content A.
For a regular user only Content A is showing if there actually exist a content B that is referring to content A.

If there only exist a Content A, and no content B that is referring to it the regular user wont see that in the view list. But for administrator it works good and I can write out the no results text for the content B listing.

What can I do to solve this?

haggan’s picture

I found a solution to my problem
In my view
Under
Query options
I had to enable "Disable SQL rewriting"

To allow the normal users to view the right results.

Status: Fixed » Closed (fixed)

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