Is there a way in Twig to make this conditional shorter so I don't use "craft.request.getSegment(2)" twice?
{% if craft.request.getSegment(2) == "knowledge" or
craft.request.getSegment(2) == "search" %}
Is there a way in Twig to make this conditional shorter so I don't use "craft.request.getSegment(2)" twice?
{% if craft.request.getSegment(2) == "knowledge" or
craft.request.getSegment(2) == "search" %}
The Containment Operator helps with this...
It returns true if the left operand is contained in the right
{% if craft.request.getSegment(2) in ['knowledge', 'search'] %}
OR
{% if craft.request.getSegment(2) not in ['', 'sale'] %}