【问题标题】:Shopify get all collections with specific templateShopify 使用特定模板获取所有集合
【发布时间】:2021-04-22 06:59:51
【问题描述】:

我正在尝试在 shopify 中创建品牌页面。为此,我有一个自定义页面模板 page.brands 和一个自定义模板 collection.brands

现在我需要遍历所有集合并仅找到使用我的自定义模板的集合。

{% for collection in collections %}

  {{ template }} // template here returns 'page.brands' not 'collection.brands'

{% endfor %}

找到了一些按名称搜索的解决方案,但如果我要添加更多集合,我还必须将名称添加到数组中。

对此有任何帮助或有什么方法吗?

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    shopify documentation找到答案

    {% for collection in collections %}
            
      {% if collection.template_suffix == "brands" %}
            
            {{ collection.title }} 
            
      {% endif %}
            
    {% endfor %}
    

    【讨论】:

      猜你喜欢
      • 2018-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-11
      • 1970-01-01
      相关资源
      最近更新 更多