Looping through an array, if matched, then change a variable

New Contributor

I have this piece of code that has left me scratching my head for a couple of days. 


I'm trying to get the URL of the current page, and if it matches one of the values in the  ignoredPaths array, it changes the variable isInIgnoredPaths to 'yes'


{% set urlPath = request.path %}
{% set isInIgnoredPaths = "no" %}
{% set ignoredPaths = ["/au/legal", "/au/careers", "/au/investor"] %}
{% for pathRow in ignoredPaths %}
{% if pathRow is string_containing urlPath %}
{% set isInIgnoredPaths = "yes" %}
{% endif %}
{% endfor %}

I've tried a few iterations of this code and I keep getting 'no'. I even went to the trouble of rebuilding this code in Javascript just to prove I wasn't losing my mind. The same logic works fine in JS.


0 replies

No replies on this post just yet

No one has replied to this post quite yet. Check back soon to see if someone has a solution, or submit your own reply if you know how to help! Karma is real.

Reply to post

Need help replying? Check out our Community Guidelines