【发布时间】:2021-04-22 19:45:12
【问题描述】:
我想在我的 shopify 收藏中的第 5 个产品之后显示一个自定义 div。有谁知道我如何在液体中做到这一点?
【问题讨论】:
标签: collections shopify liquid
我想在我的 shopify 收藏中的第 5 个产品之后显示一个自定义 div。有谁知道我如何在液体中做到这一点?
【问题讨论】:
标签: collections shopify liquid
结束产品的for循环的结尾,放一个条件喜欢
{% if forloop.index == 5 %}
<div></div>
{% endif %}
【讨论】:
使用limit/offset
{% for item in array limit: 4 %}
item less than or equal to 4
{% endfor %}
{% for item in array offset: 4 %}
item greater than 4 (5)
{% endfor %}
或使用forloop.index
{% for item in array %}
{% if forloop.index < 5 %}
do something for less than 5
{% else %}
do something greater than or equal to 5
{% endif %}
{% endfor %}
【讨论】: