I have two content types: Family and Members. Family content type has an entity reference field of type Member and can have unlimited values(multiple values). My question is: How to create a view that enables me to filter Members based on Family. Thanks
2 Answers
- Add a Contextual Filter in your view, use the "Member" field (Entity Reference guess) from your content type "Family".
- Then add a relation in Relationship section, using the same field (Member).
- Add a Title field and use that relation.
- Pass the NID of your family has an Contextual Filter in your preview... you might get all the members of that family.
Notice: in yout Contextual Filter you have to select how will you pass the Contextual Filter (Family's NID in this case). You can add it via URL, etc.
I am not very sure what you want to achieve, but you can approach it in 3 ways:
- you can display members like any other field on family page;
- you can create a block listing members on family page (or any page where you can provide family node id as contextual filter);
- you can create a drop-down of family node titles and select the select the family and corresponding list of members would appear.
- For the first situation you don't need views, you can do it with field UI: Goto Content Types > Family > Manage Display> Set Entity Reference field format to Rendered Entity
- For the second situation, you will have to create a block view ; his page has detailed instructions: https://www.drupal.org/node/1841004
- For the third situation you basically need to display the list of family as exposed filters in views; you might find this screen-cast helpful: https://youtu.be/4Pdii7aFIvc?t=16m15s