Shopify在节块中选择SVG
我正在尝试构建一个区块,允许商家在我上传到主题的snippets文件夹的多个SVG中进行选择 我这里的代码对我来说很有意义,但Shopify不会输出任何SVG。默认情况下,它变为“未选择SVG” 下面是for循环:Shopify在节块中选择SVG,shopify,liquid,Shopify,Liquid,我正在尝试构建一个区块,允许商家在我上传到主题的snippets文件夹的多个SVG中进行选择 我这里的代码对我来说很有意义,但Shopify不会输出任何SVG。默认情况下,它变为“未选择SVG” 下面是for循环: {% for block in section.blocks %} <div class="grid__item large--one-third text-center reason-block"> {% case svg__choice %}
{% 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 %}
感谢您的帮助 找到了答案。必须使用if/else而不是case。答案应该是这样的:
{% for block in section.blocks %}
<div class="grid__item large--one-third text-center reason-block">
{% if block.settings.svg == 'family' %}
{% include 'svg--family' %}
{% elsif block.settings.svg == 'bottles' %}
{% include 'svg--plastic' %}
{% elsif block.settings.svg == 'globe' %}
{% include 'svg--globe' %}
{% else %}
No SVG Selected
{% endif %}
<h4 class="h4v3">{{ block.settings.title }}</h4>
<p>{{ block.settings.text }}</p>
</div>
{% endfor %}
{%for section.blocks%}
{%if block.settings.svg=='family%}
{%include'svg--family%}
{%elsif block.settings.svg=='瓶子'%}
{%include'svg--plastic%}
{%elsif block.settings.svg=='globe%}
{%include'svg--globe%}
{%else%}
未选择SVG
{%endif%}
{{block.settings.title}
{{block.settings.text}
{%endfor%}
您的密码不正确
它必须是:
{% case block.settings.svg %}
{% when 'family' %}
{% include 'svg--family' %}
{% when 'bottles' %}
{% include 'svg--plastic' %}
{% when "globe" %}
{% include 'svg--globe' %}
{% else %}
No SVG Selected
{% endcase %}
谢谢你的解决方案。如果需要再次出现,我会尝试一下。
{% case block.settings.svg %}
{% when 'family' %}
{% include 'svg--family' %}
{% when 'bottles' %}
{% include 'svg--plastic' %}
{% when "globe" %}
{% include 'svg--globe' %}
{% else %}
No SVG Selected
{% endcase %}