0

I am interested in having one view filter for two separate fields.

Example: In a staff directory I am working on, users have both a "First Name" and "Nickname" field.

The output results show both, but in order to keep it user-friendly, I would like to have a "First Name" filter that sorts by both "First Name" and "Nickname" based on the input.

enter image description here

I found this question on here and it seems like it gives the proper direction of what I am looking for but I am not quite sure how to execute this solution.

3 separate fields,one views exposed filter

The suggestion based on the question above would be to expose both the "First Name" and "Nickname" filters but to hide the "Nickname" filter with CSS.

Following that, if a user typed a name such as "John" into the "First Name" filter and then clicked "Submit", before the query is executed, the input value "John" would also be automatically input into the CSS-hidden "Nickname" filter.

The concept makes sense to me but I am confused as to how to execute it.

Are there any detailed guides that could explain how I could make that happen? With the PHP code given in the question linked above, would I have to modify a core file? Would it be in a template file? Would it have to be in a module file?

Or is there an even simpler solution to this that I am not thinking about?

Any help is appreciated. Thank you!

  • Hey Andrew no news good news ? Did you try my answer? 100% tested and guaranted ;) – Kojo Dec 10 '15 at 18:18
  • Hi Kojo! I apologize for not replying sooner. It definitely does work and is great! But I will need to use it in the future. In this particular example, it did not quite work 100% for me. If I searched for "Veronica Lopez", it would bring back all people with first names "Veronica" and all people with last names "Lopez" rather than just any people named "Veronica Lopez". Since it's a directory and needs to be that specific, I will split the filters but for something more general in the future I will be using this!! – AndrewMRiv Dec 10 '15 at 19:45
  • Yep no worries I'm glad to know it helped. "Veronica Lopez" as a unique string search is indeed another feature request IMO, especially if you want a Combine fields filter at the same time ! – Kojo Dec 10 '15 at 21:00
1

Have you tried with an exposed Global Combine fields filter ? I'm not sure which Views version implemented that filter.

exposed Global Combine fields filter

Alternatively, you may use the Views filters populate module :

  1. Add the fields you want to search in a OR combination of filters, not exposed.
  2. Add the Global : Populate filters provided by the module (exposed), checking the filters you added in the Or group.

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.