【发布时间】:2023-04-03 13:10:02
【问题描述】:
我正在尝试编写一个允许在自定义页面中选择集合的 shopify 部分。我正在努力了解如何提取收集信息以用于该部分的液体文件。
我已经阅读了文档,并尝试了很多不同的 sn-ps,我发现这些 sn-ps 遍布互联网,但实际上似乎没有任何信息可以提取信息。
以下是我目前拥有的
p 标签是我只是看看是否有任何输出,而没有。 for 循环似乎正在工作,因为对于选择的集合数量,我得到了一个列表项(是的,我猜?) - 但这就是我所能召集的魔法。
<div data-section-id="{{ section.id }}" >
<div class="flex-wrapper ignite-collection">
<ul>
{%- for block in section.blocks -%}
<li>
<a href="{{ collection.url }}">
<img src="{{ collection.image | img_url: '350x' }}" alt="{{collection.title}}">
<h4 class="flex-collection-heading">{{ collection.title }}TEXT HEADING</h4>
</a>
// all of these p tags are left overs from me trying variations of getting info
<p>collection.image {{collections['flex-collection'].image}}</p>
<p>collection.image.url {{ collections['flex-collections'].image.url }}</p>
<p>{{ collections.flex-collection.image.url }}</p>
<p>{{ collections[settings.flex-collection].url }}</p>
<p>collection.url {{settings.flex-collection.url}}</p>
</li>
{%- endfor -%}
</ul>
</div>
</div>
{% schema %}
{
"name": "Ignite Collection list",
"class": "ignite-collection-list-section",
"max_blocks": 6,
"settings": [
{
"type": "select",
"id": "justify-content",
"label": "Justify Content",
"options": [
{"value": "flex-start", "label":"Flex Start"},
{"value": "flex-end", "label":"Flex End"},
{"value": "center", "label":"Center"},
{"value": "space-between","label":"Space Between"},
{"value": "space-around","label":"Space Around"},
{"value": "space-evenly","label":"Space Evenly"}
]
}
],
"presets": [
{
"name": "Ignite Collection list",
"category": "Collections",
"blocks": [
{
"type": "collection"
},
{
"type": "collection"
}
]
}
],
"blocks": [
{
"type": "collection",
"name": "Collection",
"settings": [
{
"id": "flex-collection",
"type": "collection",
"label": "Collection"
}
]
}
]
}
{% endschema %}
【问题讨论】: