Shopify Liquid: If Statement

后端 未结 1 1930
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-19 20:21

I am trying to enable a div class based on when a user views certain web page eg: blog, index or ../page/webpage

The code is like this:

{% unless tem         


        
相关标签:
1条回答
  • 2021-01-19 20:40

    Multiple conditions in if statements don't work so well in liquid. See a similar question here.

    One option is to use nested if statements:

    {% if template == "index" or template == "page" %}
      {% if settings.slideshow_enabled %}
        <div class="container main content">...</div>
      {% endif %}
    {% endif %}
    

    Or something like this:

    {% if template == "index" or template == "page" %}
      {% assign correct_template = true %}
    {% endif %}
    {% if correct_template and settings.slideshow_enabled %}
      <div class="container main content">...</div>
    {% endif %}
    
    0 讨论(0)
提交回复
热议问题