1

I have 3 node types. A, B and C.

A has an entity reference to B. B has an entity reference to C.

A has a list field. One of the values is "4". I need to display all node of type C where the top parent of type A has the value 4 in this list field.

I created a 'relationship referencing entity:field_in_type_a_reference_to_type_b'. And I created a context filter 'provide default value:4' with the relationship.

This part works. Only nodes of type B with parent nodes with list value '4' are displayed.

But I need the filter for one reference level deeper, for nodes of type C. I created one more relationship referencing entity:field_in_type_b_reference_to_type_c with the relationship. I tried this relationship with and without the other relationship.

But with no success. Nodes of type C aren't displayed.

How can I get the relationship from C to A?

2

It sounds like you're starting with node type B, whereas you should be starting with node type C.

  • Create your view with appropriate filters so that you only see nodes of type C
  • Add a "Entity Reference: Referencing entity" (not "Referenced entity) relationship for the B->C entity reference field, give it an identifier of something like "Entity B", tick "Require this relationship
  • Add another "Entity Reference: Referencing entity" relationship for the A->B entity reference field, use relationship "Entity B", give it an identifier of "Entity A", tick "Require this relationship
  • Add a filter (a regular filter, not a contextual one) requiring that your field has a value of "4", use relationship "Entity A"
0

Follow these steps in view.

  1. First add Entity Relationship "A bridge to the Content entity that is referencing Content via field_a_refer" i.e content type A which is referred in content type B.
  2. Then add Entity Relationship "A bridge to the Content entity that is referencing Content via field_b_refer".In relationship dropdown of this select "Content referencing Content from field_a_refer".
  3. For each fields that you want to display, select from Relationship "Content referencing Content from field_b_refer".
  4. In Filter add filter for value 4.
0

Here is also a good explanation with structured pictures, related to your problem. http://atendesigngroup.com/blog/making-sense-drupal-views-relationships-and-entity-references

By reason below i will add this. On this site you get a good lead on the difference between REFERENCING and REFERENCED when adding an Entity Reference as as a Relationsship in VIEWS. The example adding relations and walking up-streams and down-streams in three related Nodes-content-types crelation, to get the right Node related to the Views relation. The trick is to understand the Entity relations "two way relations" and use it in Views.

  • Hi Göran, while this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. Please take a look here: Why and how are some answers deleted? – bummi Jun 10 '15 at 15:45
  • I am not sure I fully understand - copyright's on pages ie from this site who has picture and text. If the page not say "free to copy" it's a bad idea to copy picture and text (against the law). But in the Principe I agree with your technical argument, and when possible i will do it your way. ;) – Göran Jun 12 '15 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.