【问题标题】:Shopify show collection description on conditionsShopify 在条件下显示集合描述
【发布时间】:2018-06-21 08:06:28
【问题描述】:

我想显示“测试”集合页面的描述。

如果网址是mysite.com/collections/test,那么它会显示描述部分。

但如果 url 有额外的标签,例如:mysite.com/collections/test/big 它不会显示描述。

我尝试使用下面的代码,但没有成功:

{% if collection.description != blank %}
    {% if collection.url == '/collections/test' %}
    <div class="collection-description regular-content mb30">
      {{ collection.description }}
    </div>
      {% endif %}
      {% endif %}

请帮我解决这个问题。谢谢。

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    只需在第一个if 中添加一个额外的条件,它将检查您是否添加了任何标签。

    {% if collection.description != blank and current_tags == blank %}
        <div class="collection-description regular-content mb30">
            {{ collection.description }}
        </div>
    {% endif %}
    

    current_tags 对象列出了产品/文章过滤中使用的所有标签。

    更多信息在这里:https://help.shopify.com/themes/liquid/objects/current-tags

    【讨论】:

      猜你喜欢
      • 2018-02-24
      • 1970-01-01
      • 1970-01-01
      • 2015-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-16
      • 1970-01-01
      相关资源
      最近更新 更多