如何将自定义 html 块添加到页脚选项列表?

问题描述

我在 Shopify 上使用 Debut 主题并想自定义我的页脚 (my site)

自定义主题中有选项可以添加删除页脚的列部分,但是没有选项可以添加自定义 html 块作为列之一。如何将自定义 HTML 添加到此页脚列选项列表中?:

current footer options

感谢您的帮助!

解决方法

打开 /sections/footer.liquid 然后向 blocks 数组添加一个新的部分块,这段代码应该给你一个基本的起点:

{
  "type": "html_content","name": "HTML Content","settings": [
    {
      "type": "html","id": "html_area","label": "Custom HTML","default": "<div><p>Some HTML content</p></div>"
    }
  ]
}

然后要显示内容,您需要为 html_content 块中的 {%- case block.type -%} 类型添加新的类型检查,如下所示:

{%- case block.type -%}
  {%- when 'newsletter' -%}
    .
    .
    .
  {%- when 'text' -%}
    .
    .
    .
  {%- when 'link_list' -%}
    .
    .
    .
  {%- when 'html_content' -%}
    {{ block.settings.html_area }}
{%- endcase -%}

当您保存更改并刷新主题定制器时,您应该能够在页脚部分看到一种新的内容类型。

对于所有主题部分输入类型 refer to this doc