简体   繁体   English

自定义创建的部分未显示 - Dawn 2.0 Shopify

[英]Custom Created Section Not Showing Up - Dawn 2.0 Shopify

Shopify Dawn 2.0 Theme RE: Countdown Timer Shopify 黎明 2.0 主题 RE:倒数计时器

Im trying my hand at the Shopify code framework.我正在尝试 Shopify 代码框架。

I want to make my own countdown timer and to start, I have duplicated the Announcement Bar code in Sections and named it countdown.我想制作自己的倒数计时器并开始,我复制了部分中的公告条码并将其命名为倒数。

I have also duplicated the anncoument bar css.我还复制了公告栏 css。

I have renamed everything annoucement to countdown - to not confuse both in css and html classes.我已将所有公告重命名为倒计时 - 不要混淆 css 和 html 类。

I have gotten as far as to have the Count Timer appear as a selectable section in the Customiser but when it is active, it is not showing up.我已经让计数计时器在定制器中显示为可选部分,但是当它处于活动状态时,它没有显示出来。

[Screenshot of the Customiser and by Countdown Timer appearing][1] [定制器和倒数计时器出现的屏幕截图][1]

I noticed it does not have a similar icon as the header / announcement bar would.我注意到它没有与 header / 公告栏类似的图标。

What am I doing wrong?我究竟做错了什么?

Here is my current code:这是我当前的代码:

  {%- case block.type -%}
    {%- when 'countdown' -%}
      <div class="countdown-bar color-{{ block.settings.color_scheme }} gradient" role="region" aria-label="{{ 'sections.header.countdown' | t }}" {{ block.shopify_attributes }}>
        {%- if block.settings.text != blank -%}
          {%- if block.settings.link != blank -%}
            <a href="{{ block.settings.link }}" class="countdown-bar__link link link--text focus-inset animate-arrow">
          {%- endif -%}
              <p class="countdown-bar__message h5">
                {{ block.settings.text | escape }}
                {%- if block.settings.link != blank -%}
                  {% render 'icon-arrow' %}
                {%- endif -%}
              </p>
          {%- if block.settings.link != blank -%}
            </a>
          {%- endif -%}
        {%- endif -%}
      </div>
  {%- endcase -%}
{%- endfor -%}

{% schema %}
{
  "name": "Countdown Timer",
  "max_blocks": 2,
  "blocks": [
    {
      "type": "announcement",
      "name": "Countdown Timer",
      "settings": [
        {
          "type": "text",
          "id": "text",
          "default": "We must edit the code to configure the timer",
          "label": "t:sections.countdown-bar.blocks.countdown.settings.text.label"
        },
        {
          "type": "select",
          "id": "color_scheme",
          "options": [
            {
              "value": "background-1",
              "label": "t:sections.countdown-bar.blocks.countdown.settings.color_scheme.options__1.label"
            },
            {
              "value": "background-2",
              "label": "t:sections.countdown-bar.blocks.countdown.settings.color_scheme.options__2.label"
            },
            {
              "value": "inverse",
              "label": "t:sections.countdown-bar.blocks.countdown.settings.color_scheme.options__3.label"
            },
            {
              "value": "accent-1",
              "label": "t:sections.countdown-bar.blocks.countdown.settings.color_scheme.options__4.label"
            },
            {
              "value": "accent-2",
              "label": "t:sections.countdown-bar.blocks.countdown.settings.color_scheme.options__5.label"
            }
          ],
          "default": "accent-1",
          "label": "t:sections.countdown-bar.blocks.countdown.settings.color_scheme.label"
        },
        {
          "type": "url",
          "id": "link",
          "label": "t:sections.countdown-bar.blocks.countdown.settings.link.label"
        }
      ]
    }
  ],
  "default": {
    "blocks": [
      {
        "type": "announcement"
      }
    ]
  }

}
{% endschema %}```

  [1]: https://i.stack.imgur.com/HDlMz.png

You need to add presets to end of section schema.您需要将预设添加到部分架构的末尾。

"presets": [
  {
    "name": "Countdown Timer"
  }
]

I have been adding custom sections to my site and have created a checklist to make it easier for me to do so, as it turned out there were some (for a newbie like me) nonintuitive things that you need to do.我一直在向我的网站添加自定义部分,并创建了一个清单以使我更容易这样做,因为事实证明,您需要做一些(对于像我这样的新手)不直观的事情。

What you likely missed is that you need to edit the json file that is being used by your site.您可能错过的是您需要编辑您的站点正在使用的 json 文件。 In my case, that is en.default.schema.json.就我而言,即 en.default.schema.json。 In the json file, lookup the name of the section that you copied and renamed and duplicate the info and edit it to the new section name as you did in the section code.在 json 文件中,查找您复制和重命名的部分的名称,复制信息并将其编辑为新的部分名称,就像您在部分代码中所做的那样。

As a reference, here is my checklist:作为参考,这是我的清单:

To create a new section:要创建一个新部分:

  1. Add a new section添加新部分
  2. Name section logically逻辑地命名部分
  3. Add code copied from a similar section, edit code添加从类似部分复制的代码,编辑代码
  4. Search code for "render" items “渲染”项目的搜索代码
  5. Copy code in the render item and create a new snippet with the copied code复制渲染项中的代码并使用复制的代码创建一个新片段
  6. Edit code in snippet and add notes to each edit with details, reason, date在片段中编辑代码并为每个编辑添加注释,包括详细信息、原因、日期
  7. Edit section schema to represent the new section name编辑部分架构以表示新的部分名称
  8. Edit en.default.schema.json with new section details使用新的部分详细信息编辑 en.default.schema.json

Did you add the section into the template?您是否将该部分添加到模板中? I created a cheatsheet for new sections with a kind of a hierarchy:我为具有某种层次结构的新部分创建了备忘单:

New Section Checklist新部分清单

  1. Template.JSON模板.JSON
  2. Sections.liquid Sections.liquid
  3. Default Schema默认架构
  4. CSS Styling (optional) CSS 造型(可选)

1-3 need to be modified for your new section to show up and work, 4 is optional if you want to add some styling to your section.需要修改 1-3 以使您的新部分显示和工作,如果您想为您的部分添加一些样式,则 4 是可选的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM