themes - 在shopify主题的 "blocks"中添加 'settings_schema.json'

标签 themes shopify

我是 Shopify 的新手,正在 Shopify 中构建自定义主题,我想在 settings_schema.json 中添加“ block ”,就像我在部分架构中添加的那样,这可能吗?如果是的话我该如何添加它?请帮助我
我添加了以下代码:

    [
  {
    "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"
          }
        ]
      }
    ]
  }
]

但它给出了一个错误:

Error: Section 2: 'blocks' is not a valid attribute

也欢迎任何其他解决方案

最佳答案

settings_schema.json 文件不支持 block 。

仅在 {% schema %}{%endschema %} 标记内的节文件内支持 block 。

有一些解决方法可以解决您的问题。

使用链接列表

如果您必须使用settings_schema.json,则可以使用link_list字段来选择特定的link_list,您可以在其中创建一个以颜色标签作为链接标题的导航,并十六进制代码作为链接 URL 地址。

使用单独的部分

使用单独的颜色部分,您可以在其中选择 block 。

使用文本区域

您可以使用文本区域,并进行一点分割即可获得您想要的效果。

例如,文本区域的值将是:

Black|#000000
White|#ffffff
Grey|#cccccc

你会做类似的事情:

{% 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 %}

总结

最用户友好的选项是部分选项,但您可以决定最适合您的需求的选项。

关于themes - 在shopify主题的 "blocks"中添加 'settings_schema.json',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49870923/

相关文章:

android - 如何知道特定 Android 手机的颜色

visual-studio - 将当前的 .vssettings 转换为 VS 2013 的 .vstheme

android - setTheme 有效,但仅在从 list 加载主题之后

ios - 如何缓存和存储 Shopify 购物车商品?

jquery - 导航栏折叠 JQuery 未触发 - Bootstrap 3.1.1

css - @font-face - 浏览器未请求的字体,未加载

javascript - Shopify - Liquid 在 JavaScript 之前处理吗?

javascript - 结帐后收据中的 Shopify 脚本显示付款信息

c# - Windows Phone 8.1 : Change background on phone theme change (Application. 当前.资源为空)

asp.net - CSS 更改,ASP.NET 主题中的更新未显示