【发布时间】:2018-06-04 09:48:44
【问题描述】:
[![在此处输入图片描述][1]][1]我的工作太简单了,即只是在产品 thumbnail.liquid 的 div 块中添加 Amazon url。我只添加了简单的 div,然后我发现相同的 div 重复两次。我还检查了没有forloop 仍然发现它是如何重复的。今天我找到了名为product-loop.liquid 的文件,其中包含for 循环和product thumbnail.liquid。如果我只需要显示一次亚马逊链接块,我需要做什么?整个文件在 gist 链接中。谢谢。
product-loop.liquid
{% assign product_found = false %}
{% assign skip = false %}
{% assign collection_group = products | map: 'id' %}
{% assign collection_group_thumb = collection_group | append : 'thumb' %}
{% assign collection_group_mobile = collection_group | append : 'mobile' %}
{% capture new_row %}
<br class="clear product_clear" />
{% endcapture %}
<div itemtype="http://schema.org/ItemList" class="products">
{% for product in products limit: limit %}
{% if product.id == skip_product.id or skip == true %}
{% assign product_found = true %}
{% else %}
{% if forloop.rindex0 == 0 and product_found == false and forloop.length != products.count and template != 'search' %}
{% assign skip = true %}
{% else %}
{% include 'product-thumbnail', sidebar: sidebar %}
{% if products_per_row == 2 %}
{% cycle collection_group: '', new_row %}
{% elsif products_per_row == 3 %}
{% cycle collection_group: '', '', new_row %}
{% elsif products_per_row == 4 %}
{% cycle collection_group: '', '', '', new_row %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</div>
【问题讨论】:
-
你可以检查你是否在 for 循环中包含产品缩略图,这就是它重复的原因.....希望你得到它的解决方案
-
抱歉,我不知道如何仅在我不熟悉这种液体语言后才显示链接。你能指导我吗?
-
如果您与我分享详细信息,您可以在这里了解我如何为您提供帮助,以便我可以为您交叉检查并为您提供解决方案
-
当然。我如何连接你?您需要什么详细信息?
-
您能在您的系统上为我创建一个员工帐户,以便我可以登录商店