Closed (fixed)
Project:
Entity reference
Version:
7.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
30 Jan 2012 at 19:59 UTC
Updated:
18 Oct 2012 at 14:01 UTC
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
Comment #1
sonar_un commentedYou 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.
Comment #2
drupalreggie commentedI could do this in D6 using Node Reference but can't yet figure a way in D7, would be useful!
Comment #3
bpeicher commentedIf 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!
Comment #4
steven jones commentedThe answer is #3 is exactly how you'd do this.
Comment #5
sunchaser commentedfor 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)
Comment #6
haggan commentedI 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?
Comment #7
haggan commentedI 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.