Exposed filter criteria & taxononomy: make the terms appear only when relevant

Hello everyone,

I have created a view for a list of educational / touristic offers.

  • There is a header which allows to select the offers according to the audience, and then a display for each audience.

  • There is an exposed filter so that visitors car select the type of offer they are interested in.

See: https://test-voisins2.web.cern.ch/offers

My problem:
E.g. Under the “teachers” display, I would like ONLY the “Type of offers” available for teachers to appear, not all of them.
Is it possible to limit the number of terms appearing in the exposed filter criteria according to their availability in a particular display?

Let me know if my question is unclear, or need to be reformulated.

Kind regards,

Marie

Hi @mbbouvie,

This is easy to do although the way you’ve set this up will require a lot of manual work, unfortunately…

Because you have created a bunch of displays for the different audiences, you will need to edit each of them to configure the exposed filters. The method is as follows:

  1. Edit the display for which you want to limit the Type of offer selection
  2. Edit the Type of offer exposed filter
  3. Click the box ‘Limit list to selected items’ (see screenshot):
  4. Then use Ctrl+Click to toggle the terms that you want to make available to this display, and make sure you apply to selected display only, not All displays.

Hope this helps!

Note: there is an easier way to implement this kind of setup, by using contextual filters to produce the different listings for different audiences, without having to duplicate displays.

It’s too long to explain here but here’s a guide that you might find super useful: https://www.youtube.com/watch?v=FUlj6-Rb7Ds (and the follow-up video as well, Lesson 30)

1 Like

Dear Oscar,

Many thanks for your answer.

I had thought of manually selecting the terms in the contextual filter. The problem is that each time I will add a new “Offer”, I would then have to manually edit it again (because the “Type of event” can be new to the “audience”).
Is there a way to automatically create a relationship between the 2 taxonomies so that the list could update itself?

Regarding the contextual filter to avoid the duplication of displays, I would need further help to render the same view in the header as the one I have now…

Kind regards,
Marie

Hello Marie,

The closest solution I found to an automated way can be implemented by creating a Custom Module and using the code mentioned in this Stackexchange answer. Its a simple implementation so in my opinion it is doable. If you are interested in this solution, let me know and I can post a detailed response to explain exactly what you need to do.

I also found a module that does this implementation but both the module and its dependencies are in alpha/beta versions so It’s quite risky to use it, especially when it comes to an important part of your website.

Let me know if it works for you.

Konstantinos

Hi Kostas,

If the creation of a Custom Module is a solution with long term validity, I can follow your detailed response. If it requires maintenance over time, I would avoid it because I won’t be around to maintain the website forever.

Thanks for your help!

Marie