【问题标题】:How to add default URL in Sections Schema如何在部分架构中添加默认 URL
【发布时间】:2021-11-06 10:54:08
【问题描述】:

我一直在尝试为动态部分创建架构,并为某些页面使用一些预定义的默认 URL,但 Liquid 无法接受。这是架构代码:

{% schema %}
{
  "name": "My New Section",
  "class": "homepage-section",
  "tag": "section",
  "settings": [
    {
      "type": "text",
      "id": "section-heading",
      "label": "Section Heading",
      "default": "Default Heading",
      "info": "Meaningful copy in 25 characters or less."
    },
    {
      "type": "url",
      "id": "link-1",
      "label": "Link URL 1",
      "default": "/collections/mycollection"
    }
  ],
  "presets": [
    {
      "name": "My New Section",
      "category": "My Sections"
    }
  ]
}
{% endschema %}

因此,对于“type”:“url”,我尝试定义默认集合“default”:“collections/mycollection”,这是我尝试保存文件时的错误消息:

此文件包含以下错误:错误:无效架构: id="link" 默认设置必须是字符串或数据源访问 路径

我尝试了一些不同的选项但没有成功:

“默认”:“https://testing.myshopify.com/”

“默认”:“https://testing.myshopify.com/”

“默认”:“收藏/我的收藏”

“默认”:“收藏/我的收藏”

请告诉我是否有办法处理它。

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:

    您需要阅读有关 Shopify 提供的称为 URL 的特殊输入类型的文档

    根据文档,默认只能设置这2个网址:

    1. /collections
    2. /collections/all

    这是因为这是商店自动创建后出现的两个 URL,一个是为所有产品系列列表页面设置的,一个是为所有产品页面设置的。所以 Shopify 知道这两个已经存在。

    因此,这是您在 Shopify 架构中的 URL 字段中接受的两个默认值。

    【讨论】:

    • 谢谢@onkar。你提供的文件也很完整,我找了很久。我会在信息字段中指出推荐的 URL。
    • @Valladão 很高兴知道这一点
    猜你喜欢
    • 2016-07-15
    • 2012-12-12
    • 1970-01-01
    • 2013-03-30
    • 2011-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多