Dear all,
great work on BEF, I like them very much. However there is one thing I do no know how to solve.
Say I have a car sales site, and one vocabulary with brands (BMW, Skoda, …).
Then I add come cars (content type) and every car gets a brand as a taxonomy flag.
Now I use BEF to filter the available cars for the clients, but I need to only display available brands. Say I have two Skoda cars and no BMW, so I only want to show Skoda in checkbox list for the clients. Otherwise it is confusing and the people are getting "no results" way too often…
I have searched thoroughly and only found solution working in 2.x version in D6. I was not able to change it to work under 7.x 3.x. heres the link:
Would anyone be able to help me with that? Thanks!
Comments
Comment #1
Yuri CreditAttribution: Yuri commentedThis is a feature that is often needed indeed.
Comment #2
Yuri CreditAttribution: Yuri commentedIn the meantime here is a workaround: http://wearepropeople.com/blog/limiting-select-options-for-exposed-filter with some alternatives in the comments.
Comment #3
LuisFernando CreditAttribution: LuisFernando commentedI'm also in need of this functionality. Having filters that show no results is not ideal.
Comment #4
jmaag CreditAttribution: jmaag commentedI've had this same request, but for entity reference filters. I solved it similar to Yuri's link (#2), but using Views to handle the database querying. I had an entity reference field on a Research content type, referencing Specialty nodes. The end result was a research listing page with a select list of specialties to filter the research. I'll explain it in my particular case because I think it's easier to grasp, but can be extended to any entity reference relationship between content types.
I created a View that output every Specialty node id that was referenced on the Research node. I used this output to remove no results content in a form alter. Here was my process for the view:
The preview should now show all the Specialty Node IDs that are referenced by Research nodes. I use this output to remove items from the exposed filter on the research list page. Here's the code with comments and all caps where appropriate:
Comment #5
mikeker CreditAttribution: mikeker commentedWhat you're asking for is called faceted search and usually requires additional indexing on the server by a Apache Solr or similar. Take a look at the FacetAPI module for this, keeping in mind that you will not be able to use BEF to render your exposed filters if you're using FacetAPI.
Comment #6
jalapi CreditAttribution: jalapi commentedThere is a great module available for this. Check it out. Works with BEF as well!
https://www.drupal.org/project/views_selective_filters
Comment #7
RealGecko CreditAttribution: RealGecko commented#6 works brilliantly.
Comment #8
canardesign CreditAttribution: canardesign commented#6 saved me hours of coding, simple and effective, thanks !
Comment #9
Spanners CreditAttribution: Spanners as a volunteer commentedI got stuck on this problem for a little while and then found Selective Better Exposed Filters.
Thanks to tonytheferg for this post on Drupal Stack Exchange.
I was already using Better Exposed Filters to show my two sets of taxonomy terms as radio buttons. The it was simply a matter of ticking the following two options in the BEF settings on my View:
1. Show only used terms
2. Filter terms based on filtered result set (you might not need this - this is so any other filters that are selected will cause the displayed terms to change to show only the terms in the current set of listed nodes)
Comment #10
neeban CreditAttribution: neeban as a volunteer commentedDo we have default out of box same functionality in drupal 10 ?