在shopify主题中的'settings_schema.json'中添加“blocks”

时间:2018-04-17 06:02:32

标签: themes shopify

我是Shopify的新手并在Shopify中构建我的自定义主题我想在settings_schema.json中添加“blocks”,因为我在节模式中添加了,是否可以?如果是,那么我该如何添加呢?请帮帮我 我添加了以下代码:

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

但是它给出了一个错误:

  

错误:第2节:'blocks'不是有效属性

任何其他解决方案也表示赞赏

1 个答案:

答案 0 :(得分:3)

MainActivity main; 文件中不支持块。

仅在settings_schema.json标记内的部分文件内支持块。

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

使用链接列表

如果必须使用{% schema %}{% endschema %},则可以使用settings_schema.json字段选择特定的link_list,您可以在其中创建带有颜色标签的链接标题和十六进制代码作为链接网址的导航。

使用seprate部分

对于您可以选择块的颜色,请使用单独的部分。

使用textarea

你可以使用textarea,只需稍微分开就可以获得你想要的效果。

例如,textarea的值为:

link_list

你会做类似的事情:

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

总结

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