1

The Craft site shows an example using a single comparison

Building upon this example from that page:

craft.entries.width('>= 100')

Can I do something similar but where 'width' is ALSO less than or equal to 200?

Conceptually:

craft.entries.width('>= 100 && <= 200')

Tyler Willingham
  • 758
  • 4
  • 14

2 Answers2

3

You can combine multiple criteria like so:

{% set entries = craft.entries.width('and, >= 100, <= 200') %}

but what you can't do is to combine multiple statements to build more complex criteria:

{% set entries = craft.entries.width('and, >= 100, <= 200' or '>= 500') %}

in your case this wouldn't make much sense. But see my still unanswered question on this topic for another example: "Complex logic on a ElementCriteriaModel parameter?"

carlcs
  • 36,220
  • 5
  • 62
  • 139
2

You can use some basic logic with and or or like this:

craft.entries.width('and, >= 100, <= 200')
Douglas McDonald
  • 13,457
  • 24
  • 57