如何将collection.liquid添加到现有页面? [英] How to add collection.liquid to an existing page?

查看:113
本文介绍了如何将collection.liquid添加到现有页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Shopify中,我试图采用模板collection.liquid并将其呈现在另一个页面中,就像将其嵌入一样.但是我不确定如何做到这一点.

In Shopify, I'm trying to take the template collection.liquid and render it in another page, just like embedding it. But i'm not sure how to accomplish that.

{% 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 %}

推荐答案

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

I've been trying to do the same thing and kept getting errors.

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

Fixed it by making a new Snippet called list-collections and copying everything from list-collections.liquid into that. Then made a page template called page.list-collections.liquid and pasted this code into that before /div: {% include 'list-collections' %}

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

Then, I made a new page using the page.list-collections template, and entered my introductory text, images etc in that, which displays above product collections on the page when published :)

这篇关于如何将collection.liquid添加到现有页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆