Shopify 如何使用模式集合从节中输出产品
我是shopify的新手,我正在尝试展示一系列产品 我在小节中创建了一个小节,并使用shopify模式来显示此设置 页面中仅显示标题和说明 如何在页面中显示所选收藏中的所有产品?我已经在网络上搜索了一整天,寻找答案 这是我的模式 希望有人能帮助我,谢谢Shopify 如何使用模式集合从节中输出产品,shopify,shopify-template,Shopify,Shopify Template,我是shopify的新手,我正在尝试展示一系列产品 我在小节中创建了一个小节,并使用shopify模式来显示此设置 页面中仅显示标题和说明 如何在页面中显示所选收藏中的所有产品?我已经在网络上搜索了一整天,寻找答案 这是我的模式 希望有人能帮助我,谢谢 <h3>{{ section.settings.title }}</h3> <p>{{ section.settings.column_richtext }}</p> <a href="
<h3>{{ section.settings.title }}</h3>
<p>{{ section.settings.column_richtext }}</p>
<a href="{{ section.settings.collection}}"></a>
{{ section.settings.collection | products}}
{% schema %}
{
"name": "Collection list 2",
"class": "index-section",
"max_blocks": 3,
"settings": [
{
"type": "text",
"id": "title",
"label": "Heading",
"default": "Collection list 2"
},
{
"type": "richtext",
"id": "column_richtext",
"label": "Short Description",
"default": "<p></p>"
},
{
"id": "collection",
"type": "collection",
"label": "Chose a collection"
},
{
"type": "range",
"id": "grid",
"label": "Collections per row",
"min": 2,
"max": 4,
"step": 1,
"default": 3
}
],
"blocks": [
{
"type": "collection",
"name": "Collection 2",
"settings": [
{
"type": "collection",
"id": "collection2",
"label": "Collection 2"
}
]
}
],
"presets": [
{
"name": "Collection list 2",
"category": "Collection",
"blocks": [
{
"type": "collection"
},
{
"type": "collection"
},
{
"type": "collection"
}
]
}
]
}
{% endschema %}
{{section.settings.title}
{{section.settings.column_richtext}}
{{section.settings.collection | products}}
{%schema%}
{
“名称”:“收藏清单2”,
“类”:“索引部分”,
“最大积木”:3,
“设置”:[
{
“类型”:“文本”,
“id”:“标题”,
“标签”:“标题”,
“默认值”:“收集列表2”
},
{
“类型”:“richtext”,
“id”:“文本列”,
“标签”:“简短描述”,
“默认值”:“”
},
{
“id”:“集合”,
“类型”:“集合”,
“标签”:“选择了一个集合”
},
{
“类型”:“范围”,
“id”:“网格”,
“标签”:“每行集合”,
“min”:2,
“最大”:4,
"步骤":一,,
“违约”:3
}
],
“区块”:[
{
“类型”:“集合”,
“名称”:“集合2”,
“设置”:[
{
“类型”:“集合”,
“id”:“collection2”,
“标签”:“集合2”
}
]
}
],
“预设”:[
{
“名称”:“收藏清单2”,
“类别”:“收藏”,
“区块”:[
{
“类型”:“集合”
},
{
“类型”:“集合”
},
{
“类型”:“集合”
}
]
}
]
}
{%endschema%}
使用此选项访问产品:
{%- assign collection = collections[section.settings.collection] -%}
{%- for product in collection.products -%}
{{ product.title }}
{%- endfor -%}
除非在“收藏”页面上,否则无法对
收藏
对象分页。使用for
循环根据上述示例,我认为您只能获得50种产品。使用此选项访问产品:
{%- assign collection = collections[section.settings.collection] -%}
{%- for product in collection.products -%}
{{ product.title }}
{%- endfor -%}
除非在“收藏”页面上,否则无法对
收藏
对象分页。按照上面的示例,使用for
循环,我认为您只能获得50种产品。下面是部分代码添加创建新部分并添加到相关模板中
<div class="page-width">
{%- comment -%} {% if section.settings.title != blank %}
<div class="section-header text-center">
<h2>{{ section.settings.title | escape }}</h2>
</div>
{% endif %}
{%- endcomment -%}
{%- assign collection = collections[section.settings.collection] -%}
{% case section.settings.grid %}
{% when 2 %}
{%- assign max_height = 530 -%}
{%- assign grid_item_width = 'medium-up--one-half' -%}
{% when 3 %}
{%- assign max_height = 345 -%}
{%- assign grid_item_width = 'small--one-half medium-up--one-third' -%}
{% when 4 %}
{%- assign max_height = 250 -%}
{%- assign grid_item_width = 'small--one-half medium-up--one-quarter' -%}
{% when 5 %}
{%- assign max_height = 195 -%}
{%- assign grid_item_width = 'small--one-half medium-up--one-fifth' -%}
{% endcase %}
{%- assign product_limit = section.settings.grid | times: section.settings.rows -%}
<div class="grid grid--uniform grid--view-items">
{% for product in collection.products limit: product_limit %}
<div class="grid__item grid__item--{{section.id}} {{ grid_item_width }}">
{% include 'product-card-grid', max_height: max_height %}
</div>
{% else %}
{% for i in (1..product_limit) %}
<div class="grid__item .grid__item--{{section.id}} {{ grid_item_width }}">
<div class="grid-view-item">
<a href="#" class="grid-view-item__link">
<div class="grid-view-item__image">
{% capture current %}{% cycle 1, 2, 3, 4, 5, 6 %}{% endcapture %}
{{ 'product-' | append: current | placeholder_svg_tag: 'placeholder-svg' }}
</div>
<div class="h4 grid-view-item__title">{{ 'homepage.onboarding.product_title' | t }}</div>
<div class="grid-view-item__meta">
{% include 'product-price' %}
</div>
</a>
</div>
</div>
{% endfor %}
{% endfor %}
</div>
{% if section.settings.show_view_all %}
<hr class="hr--invisible"></hr>
<div class="text-center">
<a href="{{ collection.url }}" class="btn">
{{ 'collections.general.view_all' | t }}
</a>
</div>
{% endif %}
</div>
{% schema %}
{
"name": "Featured collection",
"class": "index-section",
"settings": [
{
"type": "text",
"id": "title",
"label": "Heading",
"default": "Featured collection"
},
{
"id": "collection",
"type": "collection",
"label": "Collection",
},
{
"type": "range",
"id": "grid",
"label": "Products per row",
"min": 2,
"max": 5,
"step": 1,
"default": 3
},
{
"type": "range",
"id": "rows",
"label": "Rows",
"min": 1,
"max": 5,
"step": 1,
"default": 2
},
{
"type": "checkbox",
"id": "show_vendor",
"label": "Show product vendors",
"default": false
},
{
"type": "checkbox",
"id": "show_view_all",
"label": "Show 'View all' button",
"default": false
}
],
"presets": [
{
"name": "Featured collection",
"category": "Collection"
}
]
}
{% endschema %}
{%-comment-%}{%if section.settings.title!=空白%}
{{section.settings.title | escape}}
{%endif%}
{%-endcomment-%}
{%-分配集合=集合[节.设置.集合]-%}
{%case section.settings.grid%}
{2%时为%1}
{%-assign max_height=530-%}
{%-assign grid_item_width='medium up--1/2'-%}
{3%时为%1}
{%-assign max_height=345-%}
{%-assign grid_item_width='small--1/2 medium-up--1/3'-%}
{4%时为%1}
{%-assign max_height=250-%}
{%-assign grid_item_width='small--1/2中向上--1/4'-%}
{5%时为%1}
{%-assign max_height=195-%}
{%-assign grid_item_width='small--1/2 medium-up--1/5'-%}
{%endcase%}
{%-assign product_limit=section.settings.grid |次:section.settings.rows-%}
{%用于集合中的产品。产品限制:产品\u限制%}
{%包括“产品卡网格”,最大高度:最大高度%}
{%else%}
{(1..product_limit)%%中i的%
{%endfor%}
{%endfor%}
{%if section.settings.show_view_all%}
{%endif%}
{%schema%}
{
“名称”:“特色收藏”,
“类”:“索引部分”,
“设置”:[
{
“类型”:“文本”,
“id”:“标题”,
“标签”:“标题”,
“默认值”:“特色收藏”
},
{
“id”:“集合”,
“类型”:“集合”,
“标签”:“收藏”,
},
{
“类型”:“范围”,
“id”:“网格”,
“标签”:“每行产品”,
“min”:2,
“最大”:5,
"步骤":一,,
“违约”:3
},
{
“类型”:“范围”,
“id”:“行”,
“标签”:“行”,
"min":1,,
“最大”:5,
"步骤":一,,
“违约”:2
},
{
“类型”:“复选框”,
“id”:“显示供应商”,
“标签”:“展示产品供应商”,
“默认值”:false
},
{
“类型”:“复选框”,
“id”:“显示所有视图”,
“标签”:“显示“全部查看”按钮”,
“默认值”:false
}
],
“预设”:[
{
“名称”:“特色收藏”,
“类别”:“收藏”
}
]
}
{%endschema%}
以下是章节代码添加创建新章节并添加到相关模板中
<div class="page-width">
{%- comment -%} {% if section.settings.title != blank %}
<div class="section-header text-center">
<h2>{{ section.settings.title | escape }}</h2>
</div>
{% endif %}
{%- endcomment -%}
{%- assign collection = collections[section.settings.collection] -%}
{% case section.settings.grid %}
{% when 2 %}
{%- assign max_height = 530 -%}
{%- assign grid_item_width = 'medium-up--one-half' -%}
{% when 3 %}
{%- assign max_height = 345 -%}
{%- assign grid_item_width = 'small--one-half medium-up--one-third' -%}
{% when 4 %}
{%- assign max_height = 250 -%}
{%- assign grid_item_width = 'small--one-half medium-up--one-quarter' -%}
{% when 5 %}
{%- assign max_height = 195 -%}
{%- assign grid_item_width = 'small--one-half medium-up--one-fifth' -%}
{% endcase %}
{%- assign product_limit = section.settings.grid | times: section.settings.rows -%}
<div class="grid grid--uniform grid--view-items">
{% for product in collection.products limit: product_limit %}
<div class="grid__item grid__item--{{section.id}} {{ grid_item_width }}">
{% include 'product-card-grid', max_height: max_height %}
</div>
{% else %}
{% for i in (1..product_limit) %}
<div class="grid__item .grid__item--{{section.id}} {{ grid_item_width }}">
<div class="grid-view-item">
<a href="#" class="grid-view-item__link">
<div class="grid-view-item__image">
{% capture current %}{% cycle 1, 2, 3, 4, 5, 6 %}{% endcapture %}
{{ 'product-' | append: current | placeholder_svg_tag: 'placeholder-svg' }}
</div>
<div class="h4 grid-view-item__title">{{ 'homepage.onboarding.product_title' | t }}</div>
<div class="grid-view-item__meta">
{% include 'product-price' %}
</div>
</a>
</div>
</div>
{% endfor %}
{% endfor %}
</div>
{% if section.settings.show_view_all %}
<hr class="hr--invisible"></hr>
<div class="text-center">
<a href="{{ collection.url }}" class="btn">
{{ 'collections.general.view_all' | t }}
</a>
</div>
{% endif %}
</div>
{% schema %}
{
"name": "Featured collection",
"class": "index-section",
"settings": [
{
"type": "text",
"id": "title",
"label": "Heading",
"default": "Featured collection"
},
{
"id": "collection",
"type": "collection",
"label": "Collection",
},
{
"type": "range",
"id": "grid",
"label": "Products per row",
"min": 2,
"max": 5,
"step": 1,
"default": 3
},
{
"type": "range",
"id": "rows",
"label": "Rows",
"min": 1,
"max": 5,
"step": 1,
"default": 2
},
{
"type": "checkbox",
"id": "show_vendor",
"label": "Show product vendors",
"default": false
},
{
"type": "checkbox",
"id": "show_view_all",
"label": "Show 'View all' button",
"default": false
}
],
"presets": [
{
"name": "Featured collection",
"category": "Collection"
}
]
}
{% endschema %}
{%-comment-%}{%if section.settings.title!=空白%}
{{section.settings.title | escape}}
{%endif%}
{%-endcomment-%}
{%-分配集合=集合[节.设置.集合]-%}
{%case section.settings.grid%}
{2%时为%1}
{%-assign max_height=530-%}
{%-assign grid_item_width='medium up--1/2'-%}
{3%时为%1}
{%-assign max_height=345-%}
{%-assign grid_item_width='small--1/2 medium-up--1/3'-%}
{4%时为%1}
{%-assign max_height=250-%}
{%-assign grid_item_width='small--1/2中向上--1/4'-%}
{5%时为%1}
{%-assign max_height=195-%}
{%-assign grid_item_width='small--1/2 medium-up--1/5'-%}
{%endcase%}
{%-assign product_limit=section.settings.grid |次:section.settings.rows-%}
{%用于集合中的产品。产品限制:产品\u限制%}
{%包括“产品卡网格”,最大高度:最大高度%}