我是Shopify的新手,正在Shopify中构建自定义主题,我想在设置部分模式中添加“ blocks”到settings_schema.json中,这可能吗?如果是,那我该如何添加呢?请帮我,
我添加了以下代码:
[
{
"name": "theme_info",
"theme_name": "Slate",
"theme_version": "0.11.0",
"theme_author": "Shopify",
"theme_documentation_url": "https:\/\/shopify.github.io\/slate\/",
"theme_support_url": "https:\/\/github.com\/Shopify\/slate"
},
{
"name": "Colors",
"settings": [
{
"type": "header",
"content": "General colors"
},
{
"type": "color",
"id": "color_theme",
"label": "Theme color",
"default": "#efeeeb",
"info": "Used for theme"
},
{
"type": "color",
"id": "color_primary",
"label": "Primary color",
"default": "#4d4d4d",
"info": "Used for text links, and primary buttons"
}
],
"blocks": [
{
"type": "product_colors",
"name": "Product colors",
"settings": [
{
"type": "color",
"id": "color_label",
"label": "Color label",
"default": "red"
},
{
"type": "color",
"id": "color_code",
"label": "Color code",
"default": "#ff0000"
}
]
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
但是它给出了一个错误:
错误:第2节:“块”不是有效的属性
任何其他解决方案也表示赞赏
settings_schema.json文件中不支持块。
仅在{% schema %}{% endschema %}标签内的节文件内支持块。
有一些解决此问题的方法。
如果必须使用,则settings_schema.json可以使用link_list字段来选择特定的link_list,您可以在其中创建一个导航,该导航的颜色标签为链接标题,十六进制代码为链接URL地址。
对颜色使用单独的部分,在其中可以选择块。
您可以使用文本区域,稍加拆分即可获得所需的效果。
例如,textarea的值将为:
Black|#000000
White|#ffffff
Grey|#cccccc
Run Code Online (Sandbox Code Playgroud)
您将执行以下操作:
{% assign textarea = settings.textarea | newline_to_br | split: '<br /> %}
{% for text_row in textarea %}
{% assign text_row_array = text_row | split: '|" %}
{% assign color_name = text_row_array[0] %}
{% assign color_hex = text_row_array[1] %}
...
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
最用户友好的选项是section选项,但是您可以决定最适合自己的需求。
| 归档时间: |
|
| 查看次数: |
1463 次 |
| 最近记录: |