1

I have following content types: "Person" and "Publication" and I'm showing the publications using a view on a page, showing title, year, venue and authors. The authors in "Publication" are referenced to "Person" via entity reference.

I added filter criteria so the users visiting the page can search publications based on title, author etc. The problem now is, that the field for searching by author only accepts the author's entity ID. But I want the user to search by a part of the author's name (either the entity title or a specific field in the "Person" entity).

What would be the best way to do this? I tried different ways via contextual filters, relationships and entity reference on the view, but neither of them worked for me, or I made something wrong. Any help would be appreciated!

2

Entity Reference Fields only store the entity ID. To pull other information about the referenced entity into the Views you need to add the Relationship for the ER field.

It will be called something like Content referenced from field_person.

Once you add that Relationship you unlock new Fields and Filters inside Views that relate to the Person entity.

You can now add (Content) Title Filter that uses the Relationship and it will filter text within the Title Field of the Person Content Type.

Without the Relationship the Title Field/Filter will show information about the Publication, the base type chosen for that particular View.

The same goes for other Fields/Filters. If you make them use the Relationship they will pull information from People CT.

Fields/Filters that only exist on People CT will have the Relationship prefilled, as a requirement (because that data isn't accessible in that View without the Relationship).

5
  • How would I do this? Honestly, I thought about your answer very long and tried a few things, but I still don't know what to do. "To pull other information about the referenced entity into the Views you need to add the Relationship for the ER field." Which ER field? Inside "Person", "Publication" or inside the view? What do I need to do exactly? – comniemeer Mar 1 at 20:52
  • The Person Field inside your Publication content type already makes the connection between them, so in CTs it's all present, but it only stores ID numbers. Views initially has access to everything from Publication CT, Person Field included, but it only shows number IDs in Views, the directly accessible info. All other information about people is in the Person CT, not Publication CT. But Views can use the ER between them to pull in all the Person info into Publication Views. – prkos Mar 1 at 21:30
  • Here's how: In Views third column settings there is the Relationships section. There you can go to "Add" to add a new Relationship. Choose the one called "Content referenced from field_person". If you require it the Views results will only show Publications that have the Person field filled in. If you always have the Person filled in you can go either way (Required or not). After the Relationship is present go to Add a new Filter, you will see more options this time! All the fields from Person will be present. Choose Title filter and set it to use the Relationship, this filters Person Title. – prkos Mar 1 at 21:35
  • Thank you very much, that's exactly what I wanted. I had problems finding this "Content referenced from field_person", because the default language of my site is german... – comniemeer Mar 1 at 22:13
  • It can be difficult to find even in English when you know what you're looking for. I'm glad you solved it! :) – prkos Mar 2 at 0:56

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.