0

I've got a question that I can't seem to get fixed all by myself... I've got a search form and each entry has got field with some checkboxes (in this case these are options). Now I'd like to search when they check multiple checkboxes but I can't seem to get that to work... I've set up a form in which I'm fetching a parameter and just to test it with 2 checkboxes checked I've split them up in 'week1' and 'week2' like so:

{% set week_search_query =  week1 ~ ' ' ~ week2  %}

I've tried the same with 'and' and '&' in between the quotes but can't seem to get it to work, while with the 'week1' alone like so:

{% set week_search_query =  week1 %}

it works perfectly. (if I print out the content of 'week_search_query' in this case I get

weken2017:41

with weken2017 as fieldname and 41 as value). But what I'd like to to is search by 2 checked checkboxes at once as in the first example, so I can:

craft.entries.search(week_search_query)

All help is welcome, I feel like quite a newbie ATM :-)

  • So, I've been able to find part of the solution, and I can find an "AND" solution like so: weken2017:'42, 43' Now that I got that working I discovered I actually need an "OR" solution, so the search goes on and all help is still appreciated :-) – Jan Oct 17 '17 at 14:56
1

Updating answer as question was updated

As I see it, you want to find any and all entries where the field weken2017 has either the value 42 or 43.

Assuming that I have understood this much correctly, {% set entries = craft.entries.search(['OR', 'weken2017:42', 'weken2017:43']) %}

  • My bad, it was the end of the workday, of course I ran it through search, edited my question :-). I want to run the week_search_query through the search function :-) – Jan Oct 17 '17 at 11:58
  • No worries, it happens to the best of us. Updated my answer now to reflect upon your updated question :) – Fuglsetrampen Oct 18 '17 at 8:28

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.