【发布时间】:2017-04-26 17:58:11
【问题描述】:
我目前正在开发一个 shopify 网站,需要在产品页面上创建一个过滤器。我的目标是让底漆出现在产品系列页面的不同部分。我遇到的问题是如何过滤引物。我们在产品页面中设置了一个名为“Primer”的标签。我想要的是让循环检查产品是否具有底漆标签,如果有,则将其显示为循环中的产品之一。我对 Liquid 比较陌生,所以如果可能的话,我不知道如何组合子句。我查过“Where”子句,但不完全明白它是如何工作的。
下面是代码:
<div class="{% if settings.show_collection_sidebar %}desktop-10{% else
%}desktop-12{% endif %} tablet-6 mobile-3" id="bside">
<div id="product-loop">
{% for product in collection.products %}
<div class="product {% if settings.products_per_row == '3' %}
desktop-4{% cycle ' first', '', ' last' %}
{% elsif settings.products_per_row == '4' %}
desktop-3{% cycle ' first', '', '', ' last' %}
{% endif %} tablet-half mobile-half"
id="prod-{{ product.id }}"
data-alpha="{{ product.title }}"
data-price="{{ product.price }}">
{% include 'product-listing' %}
</div>
{% endfor %}
</div>
</div>
我怎样才能过滤出想要的结果?我已经在很多地方尝试过{% if product.tags contains 'Primer' %},但无济于事。
感谢您的帮助。
【问题讨论】:
-
这段代码来自哪个页面?收藏页面还是产品页面?