【问题标题】:How to add collection.liquid to an existing page?如何将 collection.liquid 添加到现有页面?
【发布时间】:2015-03-30 04:00:59
【问题描述】:

在 Shopify 中,我尝试将模板 collection.liquid 呈现在另一个页面中,就像嵌入它一样。但我不确定如何做到这一点。

{% paginate collection.products by 50 %} 
{% include 'breadcrumb' %}
{% if settings.show_sort_by and collection.products_count > 1 %}
  {% include 'collection-sort' %}
{% endif %}
{% if current_tags.size > 0 %}
<h1>{{ current_tags.first }}</h1>
{% else %}
{% endif %}
{% if collection.description.size > 0 %}
<!--START HERO-->

<!--END HERO-->
{% endif %}
<!--START PRODUCT GRID-->
<section class="product-grid twelve columns alpha omega">
   <div id="collection_hero" class="collection_hero_class">
  <img src="http://carnegie.org/fileadmin/Media/News/press_releases/whitehouse.JPG"> 
  </div>
  {% if collection.products.size > 0 %}
    {% for product in collection.products %}
      {% include 'product-grid-item' %}
    {% endfor %}
  {% else %}
    <p id="no-products" class="animated fadeInUpBig">There aren't any products in this collection!</p>
  {% endif %}
</section>
<!--END PRODUCT GRID-->
{% include 'paging' %}
{% endpaginate %}

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    我一直在尝试做同样的事情并不断出错。

    通过制作一个名为 list-collections 的新 Snippet 并将 list-collections.liquid 中的所有内容复制到其中来修复它。然后制作了一个名为 page.list-collections.liquid 的页面模板,并将这段代码粘贴到 /div 之前:{% include 'list-collections' %}

    然后,我使用 page.list-collections 模板创建了一个新页面,并在其中输入了我的介绍性文字、图像等,发布时会在页面上显示产品集合 :)

    【讨论】:

      【解决方案2】:

      复制 collection.liquid 中的所有内容并将其粘贴到新的 sn-p 中(假设您将其称为 collection-copy.liquid)。

      然后,在要添加收藏页面的页面中,添加{% include 'collection-copy' %}

      这应该只是转储 collection-copy.liquid 中的所有内容并将其输出到您的页面。

      【讨论】:

      • 谢谢。当我这样做时,我收到“液体错误:数组'collection.products'不可分页”错误。有什么想法吗?
      • @rs202 我自己没有遇到过这个问题,但是这个页面建议使用collections[settings.frontpage_collection].products 而不是collections.products ecommerce.shopify.com/c/ecommerce-design/t/… 也许这会有所帮助?
      【解决方案3】:

      最简单的方法是:

      • 创建一个新的页面模板,例如:page.list-collections
      • 然后放在下面:{{ page.content }}这一行:

        {% section 'list-collections-template' %}

      现在在 Shopify 中创建一个新页面,然后选择新页面模板。 通常,您应该能够在页面的“自定义”部分添加新集合!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-04-24
        • 1970-01-01
        • 1970-01-01
        • 2014-10-12
        • 1970-01-01
        • 1970-01-01
        • 2021-10-14
        • 2013-06-21
        相关资源
        最近更新 更多