Shopify中的多个馆藏

时间:2015-12-06 05:56:06

标签: collections shopify liquid

我现在在页面上显示了3个收藏。

我希望在最底部有一个分页,如果有的话,将为所有3个系列加载下50个产品。

我该怎么做?

这是我的代码:

{% paginate collections.mycollection1.products by settings.pagination_limit %}
        <div style="clear:both;">
            <h1>Title</h1>
            {% assign products_per_row = "4" %}
            {% assign limit = 50 %}
            {% assign products = collections.mycollection1.products %}
            {% include 'product-loop' with settings.collection_sidebar %}
            {% include 'pagination' with settings.collection_sidebar %}
        </div>

    {% endpaginate %}

{% paginate collections.mycollection2.products by settings.pagination_limit %}
        <div style="clear:both;">
            <h1>Title</h1>
            {% assign products_per_row = "4" %}
            {% assign limit = 50 %}
            {% assign products = collections.mycollection2.products %}
            {% include 'product-loop' with settings.collection_sidebar %}
            {% include 'pagination' with settings.collection_sidebar %}
        </div>

    {% endpaginate %}

{% paginate collections.mycollection3.products by settings.pagination_limit %}
        <div style="clear:both;">
            <h1>Title</h1>
            {% assign products_per_row = "4" %}
            {% assign limit = 50 %}
            {% assign products = collections.mycollection3.products %}
            {% include 'product-loop' with settings.collection_sidebar %}
            {% include 'pagination' with settings.collection_sidebar %}
        </div>

    {% endpaginate %}

1 个答案:

答案 0 :(得分:0)

这是你可以通过使用分页来做的。我假设这三个系列的大小都相同。

  1. 首先,让我们将商店中所有商品的分页称为

    @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // TODO Auto-generated method stub super.onActivityResult(requestCode, resultCode, data); Toast.makeText(CitaServicio_Foto_1.this, String.valueOf(requestCode), Toast.LENGTH_LONG).show(); if (resultCode == RESULT_OK){ switch(requestCode){ case RQS_LOADIMAGE: Uri imageUri = data.getData(); arrayUri.add(imageUri); myFileListAdapter.notifyDataSetChanged(); break; case RQS_SENDEMAIL: Intent myIntent = new Intent(this, WelcomeNoLogin.class); this.startActivity(myIntent); break; } } }

  2. 由于您一次洗牌4个产品,因此要分页的页数将是总产品数/ 4

    final int RQS_LOADIMAGE = 0; final int RQS_SENDEMAIL = 1;

  3. 现在开始分页

    {% assign total_products = collections.all.products_count %}

  4. 现在,我们需要一个显示窗口才能用于4个产品显示

    {% assign loop_value = total_products | divided_by: 4 %}

  5. 现在已经完成,我们开始展示产品。这与所有3个集合的语法相同,只需根据需要替换集合句柄。

    {% paginate collections by loop_value %}

  6. 我们结束了分页

    {% assign window = paginate.current_page %} {% assign window_start = window | minus: 1 | times: 4 %} //4 is the number of products being displayed {% assign window_end = window | times: 4 | plus: 1 %}

  7. 需要非常仔细地注意一些重要事项:

    • 除非您从代码中动态创建“mycollection1 / 2/3”数组,否则此代码仅适用于这些集合中的前50个产品。
    • 您只能在整个页面中使用 paginate 功能一次。