2

In my situation :
I have 2 content types content type A and B
In content type B add entity reference field of content type A
In views, I want to display some values of content type A,but I also want to show some values of the first content Type B which has entity reference field to content type A.
How can i show only its first value ?

edit: Content Type B has an entity reference field to Content Type A. In the view I list all of the nodes of Content Type A.
But I also want to show some field of the first node that is referenced in Content Type B.

For example:
Content Type A has fields: title and logo.
Content Type B has fields: body and entity reference to Content Type A.
Multiple entities of Content Type B can be referenced to an entity of Content Type A.

What I want to show is:
Content Type A - Title
Content Type A - Logo
Content Type B[0] - Body

Thanks in advance!

  • you can do it using global php field – Adeel Nawaz Oct 1 '15 at 9:42
  • Thank you for your answer, Adi, but I still don't know how. – Jelle Mattez Oct 1 '15 at 9:46
  • install global php field module then select field in field section in view – Adeel Nawaz Oct 1 '15 at 10:34
  • But what do I have to put in the global php field? – Jelle Mattez Oct 1 '15 at 10:39
  • @Jelle Mattez What do you mean by but I also want to show some values of the first content Type B which has entity reference field to content type A. – Swarnendu Dutta Oct 1 '15 at 15:11
0

This is how i did it :

  1. In Views, under Advanced, add Entity Reference:Referencing entity relationship via your reference field id.

  2. In Views, under fields add the field(in this case - Body) and add the above relationship .

Note: If there are nodes of content type B that reference same nodes of content type A, those same nodes of content type A will be duplicated in the views with different values of the fields of content type B that is referencing them.

Update: To remove such duplicates, you can use Views Distinct module and then in Views under fields, select Title field(Content Type A) and under Views Distinct Settings, change to 'Filter Repeats' for Filter/Aggregate this field and save.

  • Well, that's the problem: your Note. I don't want A to be duplicated. :) – Jelle Mattez Oct 1 '15 at 18:36
  • Well i guessed so..You can use Views Distinct and then in views under fields, select Title field(Content Type A) and under Views Distinct Settings, change to 'Filter Repeats' for Filter/Aggregate this field and save. – Swarnendu Dutta Oct 1 '15 at 19:01

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.