【问题标题】:Targeting different templates in shopify在shopify中定位不同的模板
【发布时间】:2017-05-23 00:02:02
【问题描述】:
{% if product.type  == 'Patio Furniture/Salsa Table' %}

<div id="dotted" style="height: auto;border-bottom:0px;text-align: center;" class="grid-uniform wrapper">
  <div class="grid__item large--one-whole">
<img alt="woman wearing colorful apron while working with bread doe in the kitchen" src="https://cdn.shopify.com/s/files/1/1418/7648/files/BERLIN_Maud_Chalard_pour_Fermob_9.jpg?1296570615214079092">
    </div>
</div>

{% endif %}

我需要定位两个名为 product.no-variantproduct.jacquard-tablecloths 的专用模板。

这部分应该放在这里{% if product.type == 'Patio Furniture/Salsa Table' %}

我很确定 product.type 只是使用错误的后缀,我需要正确的后缀。

【问题讨论】:

  • 为什么不在管理仪表板的产品页面的产品级别设置模板?
  • 我确实设置了模板,因为我无法定位这些模板是因为它们是特殊模板。 product.no-variant 和 product-jacquard-tablecloths

标签: html css shopify


【解决方案1】:

相信你在找product.template_suffix

https://help.shopify.com/themes/liquid/objects/product#product-template_suffix

Shopify 有一份备忘单,可能会对您有所帮助。

https://www.shopify.ca/partners/shopify-cheat-sheet

【讨论】:

  • {% if product.template_suffix == 'Patio Furniture/Salsa Table' %}
    cdn.shopify.com/s/files/1/1418/7648/files/…">
    {% endif %} 由于某种原因这不起作用
  • 也许我误解了你的问题?我以为您正在尝试使用模板product.no-variantproduct.jacquard-tablecloths 在这种情况下,template_suffix 将是no-variantjacquard-tablecloths。也许你可以解释一下你想要做什么?您可以在管理员中将模板应用于不同的产品。
  • 我只是想将图像添加到特定产品,但因为它们位于不同的模板上。这没有用。 {% if product.template_suffix == '提花桌布' %}
    cdn.shopify.com/s/files/1/1418/7648/files/…">
    {% endif %}
  • 仍然不确定我是否理解正确?因此,您有两个产品模板,您希望根据哪个产品模板来显示某个图像?
【解决方案2】:

1)您确定这实际上是产品类型吗?您可以尝试打印产品类型以确定。

{{ product.type }}

2) 你可以在产品描述中使用“包含”吗?

{% if products.type contains 'Patio Furniture' OR products.type contains 'Salsa Table' %}

3) 这里是all the product fields - 标签会是更好的选择吗?

4) 请记住,对于某些字段比较,您可能必须小写。

【讨论】:

  • 我想保留这个公式。对于名为 product.no-variant 和 product.jacquard-tablecloths 的专业模板,我只需要在代码 {% if product.type == 'product' %} 中放置什么而不是 product.type
【解决方案3】:

你要找的是

{% if template contains 'jacquard-tablecloths' %}
  // Your code here
{% endif %}

注意:{{ product.template_suffix }} 仅在您只想打印当前模板的名称时有用,在您的情况下会显示“jacquard-tablecloths”。

【讨论】:

    猜你喜欢
    相关资源
    最近更新 更多
    热门标签