如何加载http://example.myshopify.com/collections/all
内容到我的shopify首页http://example.myshopify.com/
我想了一种方法,在index.liquid上硬编码<script>window.location.href='collections/all'</script>
,但我很确定这不是一种干净的方法。
我试图将整个collection.liquid的代码复制到index.liquid,但它提示我Liquid error: Array 'collection.all.products' is not paginateable.
错误,并且没有产品显示index.liquide页面。
知道如何在shopify的首页加载collections/all
吗?
我正在使用Timber Framework,因为人们建议我开始构建一个主题
内部
在Timber框架中,您可以在index.liquid:中更改此行
{% for product in collections.frontpage.products limit:4 %}
至:
{% for product in collections.all.products %}
根据您拥有的产品数量,您可能仍然希望限制显示的产品数量或对输出进行分页。
例如
{% paginate collections.all.products by 12 %}
{% for product in collections.all.products %}
...
{% endfor %}
{{ paginate | default_pagination }}
{% endpaginate %}
您包括以下内容:
{% for product in collections.all.products %}
// here you have access to each product
{% endfor %}
这将循环您的所有产品。
您可以查看http://cheat.markdunkley.com/您可以在该循环中访问哪些产品变量。