7

Got myself into a seemingly simple dead-end block with twig syntax. I need to test against multiple items:

{% set segment1 = craft.request.firstSegment %}
{% if segment1 == 'one OR two OR three' %}
DO SOMETHING
{% endif %}

What's going wrong with this bit 'one OR two OR three'? brackets?

Simon Clayson
  • 611
  • 3
  • 11

1 Answers1

9

You've just got quotes wrapped around a simple string. Try something like this instead...

{% if segment1 in ['one','two','three'] %}

That will check to see if your segment1 value is in the array of possible matches.

Lindsey D
  • 23,974
  • 5
  • 53
  • 110