I currently have this working for a single range of numbers, but I can’t figure it out for multiple ranges. I currently have it set up like this for one range, and it works. myFieldHandle: ['and', '> 0', '< 10'].
Asked
Active
Viewed 382 times
3
Alex Glover
- 51
- 1
- 2
-
Providing some of your code will help others more easily answer your question. – Dan Zuzevich Jan 31 '18 at 15:04
-
Possible duplicate of Complex logic on a ElementCriteriaModel parameter? – carlcs Jan 31 '18 at 22:51
1 Answers
3
I'm not sure if you can do this in the same query but you can use two queries, one for each range, and then merge them, something like this:
{% set range1 = craft.entries({myFieldHandle: ['and', '> 0', '< 10']}) %}
{% set range2 = craft.entries({myFieldHandle: ['and', '> 20', '< 30']}) %}
{% set entries = range1 |merge(range2) %}
Mato
- 229
- 1
- 7
-
1This is an excellent way to do it. You should query for the
ids, and then merge those, and then query by id. – Marion Newlevant Feb 01 '18 at 01:32