"If A or B" statement syntax?

Highlighted
Occasional Contributor

I'd like to have an element display on the page IF the URL of that page contains any of a handful of strings. I'd like to have this IF statement be one line (IF a OR b OR c), but I'm having trouble trying to get it to work.

 

The Operators & Expression Tests page mentions "OR" with the description, "Return true if the left or the right operand is true" but doesn't use it in any examples. The IF Statements page only shows "IF this then this, ELIF this then this" which results in duplicate blocks of code for every string.

 

For example, I would like to display the publish date of the blog post IF the URL does not contain "/home", "/voip-fundamentals" or "/voip-solutions". Right now, I'm accomplishing this with the following:

 

  {% unless content.absolute_url is string_containing '/home' %}
  {% unless content.absolute_url is string_containing '/voip-resources/voip-fundamentals' %}
  {% unless content.absolute_url is string_containing '/voip-resources/voip-solutions' %}
        <em>Published: {{ content.publish_date|datetimeformat('%B %e, %Y') }}</em>
  {% endunless %}
  {% endunless %}
  {% endunless %}

This isn't very pretty or scalable. I've tried the following with no success:

 

  {% unless content.absolute_url is string_containing '/home' or content.absolute_url is string_containing '/voip-resources/voip-fundamentals' or content.absolute_url is string_containing '/voip-resources/voip-solutions' %}
  <em>Published: {{ content.publish_date|datetimeformat('%B %e, %Y') }}</em>
  {% endunless %}
  {% unless content.absolute_url is string_containing '/home' or '/voip-resources/voip-fundamentals' or '/voip-resources/voip-solutions' %}
  <em>Published: {{ content.publish_date|datetimeformat('%B %e, %Y') }}</em>
  {% endunless %}

Is it possible to do this with HubL?

Reply
0 Upvotes

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