【发布时间】:2021-01-29 13:20:28
【问题描述】:
我正在尝试使用 Liquid 和 Schema 为 shopify 创建一个图库部分。在对代码进行一些处理后,主题编辑器呈现无响应或崩溃。我已尝试删除正在编辑的主题并发布备份,但备份主题的编辑器也会崩溃(即使该版本上甚至不存在新部分)。
一两天后,它似乎工作正常,但如果我创建另一个部分进行测试,它会再次无响应。真的不知道我在这里错过了什么。起初,Shopify 支持告诉我这是在他们这边,但事实并非如此,因为它发生在我创建新部分时。他们的解决方案是更新我没有发生的主题,因为我已经完成了广泛的自定义,并且 Shopify 的主题版本控制很糟糕。无论如何,这是我要创建的部分:
<div class="grid grid--no-gutters image-bar image-bar--{{ section.settings.section_height }}">
{% for block in section.blocks %}
<div class="image-wrap" style="background-image: url('{{ block.settings.image | img_url: '500x500' }}');">
<h3>{{ block.settings.mention-text }}</h3>
</div>
{% endfor %}
</div>
{% schema %}
{
"name": "Galeria",
"settings": [
{
"type": "select",
"id": "per-row",
"label": "Images per row",
"options": [
{
"value": "49.5%",
"label": "2 per row"
},
{
"value": "33%",
"label": "3 per row"
},
{
"value": "24.5%",
"label": "4 per row"
}
],
"default": "24.5%"
},
{
"type": "select",
"id": "height",
"label": "Image Height",
"options": [
{
"value": "100px",
"label": "100px"
},
{
"value": "200px",
"label": "200px"
},
{
"value": "300px",
"label": "300px"
},
{
"value": "410px",
"label": "450px"
},
{
"value": "500px",
"label": "500px"
}
],
"default": "500px"
}
],
"blocks": [
{
"type": "image",
"name": "Image Block",
"settings": [
{
"type": "image_picker",
"id": "image",
"label": "Image"
},
{
"type": "text",
"id": "mention_text",
"label": "Mention user",
"placeholder": "@"
}
]
}
],
"presets": [
{
"category": "Galeria",
"name": "Galeria"
}
]
}
{% endschema %}
{% style %}
.image-wrap {
display: inline-block;
width: {{section.settings.per-row}};
height: {{section.settings.height}};
background-size: 100%;
}
.page-width.galeria-testimonial {
width: 90%;
margin: 0 auto;
}
{% endstyle %}
【问题讨论】:
标签: themes shopify liquid database-schema shopify-template