5

I have 2 Content Types : Activity and Event

For each of Event node, there will be an Entity Reference field which References Activity Node.

Example:

Event: Title:Hiking in Utah Activity: Hiking (Entity reference field referencing Activity node hiking)

I am Referencing Activity In an Entity Reference Field in Event Content type...

How can we use "Referenced Entity" within Views and make them available as Exposed Filters ?

Here is a screenshot to the Views setting and current output: Screen-shots In the end I want the Referenced Entities to be visible in a Dropdown field and filter results on selection.

Ive had a look at EVA, but i am unable to understand if that can be used to accomplish this.

14

You have to actually go into your entity reference field settings on your content type and enable the following:

Render Views filters as select list. Provides a select list for Views filters on this field. This should not be used when there are over 100 entities, as it might cause an out of memory error.

This will then allow your exposed filter in views to be rendered as a select list.

  • that worked perfectly, however i will be having more than 100 nodes in some content types which i will be referencing via Entity Reference. In that case can i keep using this structure as it is advised not to be used when there are over 100 entities ? – SNaushadS Aug 2 '13 at 17:49
  • My understanding (as I recall reading some notes from the maintainer in a thread somewhere) is that this feature is pretty hacky. Therefore you are going to see a performance issue using it past 100 nodes. You are better off just using the textfeild by default. – Nigel Waters Aug 2 '13 at 17:54
  • actually i intended to use Taxonomy to relate contents. Say each content type would have a taxonomy, however i got that there are taxonomies for each content type, which didn't seem useful to me and i had to create Taxonomy each time a node was created (or automate this in some way). Entity ref, appeared to resolve this issue. Any better suggestion ? Also, im unable to undersand "textfield" that you have mentioned. Or should i stick to using Taxonomy, itself. I need to be able to use them as Filters as well as for displaying "related" content in views blocks. – SNaushadS Aug 2 '13 at 18:22
  • I would use taxonomy and use the inline entity reference module in conjunction with the term ref field. This way you can create new terms on the node add/edit page. However, I don;t know the entire ins and outs of what you are trying to do so it is really not a definitive answer, only a recommendation. – Nigel Waters Aug 2 '13 at 18:35
  • thanks for the answer, time and suggestion. Ill go with Taxonomy route at the moment, without any complexity as im not getting it :) – SNaushadS Aug 2 '13 at 18:45
4

There is a better way to handle this using the Views Reference Filter Module

Create your view and reference it in your view in a field.

This module provides the views filter for entity ID or entity reference fields:

  • node ID
  • user ID
  • taxonomy term ID
  • term reference field (Drupal core)
  • entity reference field (Entity reference module)
  • Ah, this is the way to go! Thank you! For others, remember to save the reference view you create, it won't show up on the drop down until the view is saved. – TelFiRE Jun 30 '15 at 10:41
0

You can do this natively with Views. Add a relatinoship on the entity field, and a field as a filter and set it to use the relationship.

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.