【问题标题】:Custom made sections not appearing with Shopify's new theme editorShopify 的新主题编辑器未显示自定义部分
【发布时间】:2017-02-13 08:52:39
【问题描述】:

随着新主题编辑器的发布,我被分配使用 Shopify 的新主题构建器框架来构建新客户的网站。

一切都很好,只是当我在后端创建一个新的“部分”时,它没有出现在主题编辑器的“部分”区域中。

知道这里出了什么问题吗?是否有另一个 JSON 文件与我缺少的部分相关联?

<div id="callToActions">
  <div class="grid grid--no-gutters">
    <div class=""></div>
  </div>
</div>



{% schema %}
{
  "name": "Call to Actions",
  "class": "index-section index-section--flush",
  "settings": [
    {
      "id": "cta_1_title",
      "type": "text",
        "label": "CTA 1 Title",
      "default": "Dryups Specials"
    }
  ]
}
{% endschema %}

【问题讨论】:

  • 在您将其包含在您的主题/液体文件中之前,该部分不会显示在主题编辑器中。

标签: themes shopify liquid sections


【解决方案1】:

你快到了,只是缺少一件事。只有定义了预设的部分才会显示为要添加的选项。

此更新将使其显示:

{% schema %}
{
  "name": "Call to Actions",
  "class": "index-section index-section--flush",
  "settings": [
    {
      "id": "cta_1_title",
      "type": "text",
      "label": "CTA 1 Title",
      "default": "Dryups Specials"
    }
  ],
  "presets": [{
    "name": "Call to Actions",
    "category": "Text"
  }]
}
{% endschema %}

注意类别。如果省略,它将在 Miscellaneous 下结束。

【讨论】:

  • 我希望 Shopify 文档对此有说明。例如警告或容易注意到的东西。过去几周一直在开发一个主题,我无法相信他们的文档中经常缺少这种重要的笔记。
  • 我添加了预设,但我的部分仍未显示在我的自定义页面中。
  • 预设仅用于在主页“添加栏目”列表中显示栏目。对于自定义页面(或任何其他模板),您需要将其包含为自定义部分:{% section 'your-section' %}
  • 在 2021 年仍然相关(使用 OS 2.0),除了部分架构文章的预设部分之外,仍然没有提及它。好像我们应该从大学或祖先那里知道这一点
  • 这在任何部分的文档中都不存在,shopify.dev/themes/architecture/sections 很高兴在 Stack 而不是 Sopify 论坛上看到一些 Shopify 开发讨论。
猜你喜欢
  • 2022-07-28
  • 2021-04-15
  • 2019-09-16
  • 2022-01-20
  • 2021-01-29
  • 2018-05-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多