我正尝试在电子商务商店中为我的产品页面添加面包屑。我需要一些液体语法的帮助。液体中的面包屑
我想包括第一个产品标签作为面包屑的一部分,除非标签是'贴纸','信纸'或'配件',在这种情况下,我想使用第二个标签。如果第二个标签也是“贴纸”,“文具”或“配件”,我想使用第三个标签,依此类推。
也许更好的方式来说这将是:我想打电话给第一个可用的标签,不是'贴纸','文具',或'配件'。
我已经得到最接近的是这样的:
{% if product.tags.first contains 'stickers' or product.tags.first contains 'stationery' or product.tags.first contains 'accessories' %}
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/collections/all/{{ product.tags.last }}" itemprop="url"><span itemprop="title">{% if product.tags.size > 0 %}{% assign words = product.tags.last | split: '-' %}{% for word in words %}{% if word == 'and' %}{{ word }} {% else %}{{ word | capitalize }} {% endif %} {% endfor %}{% endif %}</span></a></li>
{% else %}
<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="/collections/all/{{ product.tags.first }}" itemprop="url"><span itemprop="title">{% if product.tags.size > 0 %}{% assign words = product.tags.first | split: '-' %}{% for word in words %}{% if word == 'and' %}{{ word }} {% else %}{{ word | capitalize }} {% endif %} {% endfor %}{% endif %}</span></a></li>
{% endif %}
这是不雅,但它的工作原理,直到一个点。第一个标签和最后一个标签都属于我想要排除的类别之一。
据我所知,似乎没有一个选项可以调用像“product.tags.second”(只有“第一”和“最后”似乎工作)。
我有点超出了我的深度,真的很感谢一些关于如何解决这个问题的建议。
我在的平台是Shopify。
谢谢!
你不能只在产品标签复制到其他一些变量,并删除您所谈论的三个标签,然后就显示,截至面包屑? –
听起来好像是逻辑上的声音 - 但是,我不知道如何去做你的建议 – Ben
只需要补充,下面Steph发布的解决方案概述了如何实现你的建议。干杯。 – Ben