Shopify - 产品循环中的模板检查
Shopify - Template check within product-loop
有人知道可以在产品循环中检查模板吗?因此,如果所列产品的模板之一不同,我需要以某种方式知道。
有什么想法吗?
您可以使用全局 template
变量来访问用于呈现当前页面的模板的名称。例如:
{% if template contains 'product' %}
This is a product page...
{% endif %}
或者您可能需要 product.template_suffix
:
Returns the name of the custom product template assigned to the product, without the product.
prefix nor the .liquid
suffix. Returns nil
if a custom template is not assigned to the product.
Input
<!-- on product.wholesale.liquid -->
{{ product.template_suffix }}
Output
wholesale
有人知道可以在产品循环中检查模板吗?因此,如果所列产品的模板之一不同,我需要以某种方式知道。 有什么想法吗?
您可以使用全局 template
变量来访问用于呈现当前页面的模板的名称。例如:
{% if template contains 'product' %}
This is a product page...
{% endif %}
或者您可能需要 product.template_suffix
:
Returns the name of the custom product template assigned to the product, without the
product.
prefix nor the.liquid
suffix. Returnsnil
if a custom template is not assigned to the product.Input
<!-- on product.wholesale.liquid --> {{ product.template_suffix }}
Output
wholesale