【发布时间】:2018-07-30 18:29:47
【问题描述】:
我正在尝试构建一个块,允许商家在我上传到主题的 sn-ps 文件夹的多个 SVG 之间进行选择。
这里的代码对我来说很有意义,但 Shopify 不会输出任何 SVG。它默认为“未选择 SVG”。
这里是for循环:
{% for block in section.blocks %}
<div class="grid__item large--one-third text-center reason-block">
{% case svg__choice %}
{% when block.settings.svg == 'family' %}
{% include 'svg--family' %}
{% when block.settings.svg == 'bottles' %}
{% include 'svg--plastic' %}
{% when block.settings.svg == "globe" %}
{% include 'svg--globe' %}
{% else %}
No SVG Selected
{% endcase %}
<h4 class="h4v3">{{ block.settings.title }}</h4>
<p>{{ block.settings.text }}</p>
</div>
{% endfor %}
这是我的 {% schema %}:
"blocks": [
{
"type": "select",
"name": "Standard Block",
"settings": [
{
"type": "select",
"id": "svg",
"label": "Select SVG code",
"options": [
{
"value": "family",
"label": "Family"
},
{
"value": "globe",
"label": "Globe"
},
{
"value": "bottles",
"label": "Bottles"
}
],
"default": "family"
},
{
"type": "text",
"id": "title",
"label": "Block Title"
},
{
"type": "textarea",
"id": "text",
"label": "Block Paragraph"
}
]
}
]
感谢任何帮助!
【问题讨论】: