1

Is it possible to combine two filter criteria exposed filter into one dropdown. In drupal 8 I am creating a view to search certain content type. One of the content type has three select list field, I do not want to create three seperate exposed filter dropdown on the search page, Is there is a way to combine all into one exposed filter dropdown ?

Any suggestions and guidance deeply appreciated.

1 Answer 1

1

Even with Better Exposed Filters you will not achieve what you need. As I understood you want one selectbox for the end user which merges three different fields of your content type?

This is not possible out of the box. When filtering the name of the selectboxes and the chosen values will be added to the URL like "?selectbox1=123&selectbox2=abc&selectbox3=xyz" (not exactly, but this is not important). Views does it for you to translate these URL parameters into the field names and the database query.

For your idea you need a way to tell Drupal that "?my_merged_selectbox[]=123&my_merged_selectbox[]=abc&my_merged_selectbox[]=xyz" needs to be somehow translated into the seperated filters / field names and values like above.

The only way would be to write your own views filter plugin. Helpful link: https://zanzarra.com/blog/custom-views-filter-plugin-drupal-8-bounding-box-geofield

I do not know if you have programming skills but what you want to achieve will need custom programming and is not trivial.

1
  • Hi Tobias, first thank you for your reply. Yes, I was exactly looking for the single drop down for the end user wihich merges three different fields. Yeah I think custom plugin is the way. I have a bit of programming skills thank you for sharing the link.
    – mathen
    Sep 15, 2020 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.