JSON 模板中包含的分区和块的设置可供商家选择将一个或多个动态源连接到该设置,具体取决于设置类型。
动态源可以是:
- 元字段值
- 资源属性
注意
动态源不可用于常规主题设置。
可用值
Shopify 根据以下内容确定每种可用动态源类型的值:
- 该分区所在模板的相关资源
- 当前设置情景中的资源设置
例如
条件 | 描述 |
该分区是产品模板的一部分 | 与产品相关的元字段和属性可用于以下内容: 分区的设置 分区中任何块的设置 |
该分区包含集合类型设置 | 与集合相关的元字段和属性可用于以下方面: 分区的设置 分区中任何块的设置 |
该分区的块包含产品类型设置 | 该产品的元字段和属性将可用于区块的设置 |
以下表格列出了可用的资源及其相关属性:
资源 | 属性 |
product | title vendor |
collection | title image |
page | title url |
article | title url author image |
blog | title url |
以下概述了哪些设置和元字段类型将与之兼容:
设置 | 元字段 | 元字段验证选项 |
collection | collection_reference | |
collection_list | list.collection_reference | |
color | color | |
image_picker | file_reference | |
page | page_reference | |
product | product_reference | |
product_list | list.product_reference | |
richtext | single_line_text_field list.single_line_text_field multi_line_text_field number_integer number_decimal date date_time weight volume dimension rating money | |
text | single_line_text_field list.single_line_text_field number_integer number_decimal date date_time weight volume dimension rating money | |
url | url | |
video | file_reference | 必须接受视频文件类型 |
默认值
您可以将设置的默认值配置为引用动态源。不过,只有在动态源值存在的情景渲染分区或块时,才可以这样做。例如,不要在以下分区中使用与产品相关的值:
- 可在非产品模板中渲染
- 没有明确的产品类型设置来提供必要的值
注意
这也适用于在预设中设置值。
使用此方法时,附加 Liquid 无效,因此只能直接引用该值。如果包含附加 Liquid,则会出错。
下面是一个引用动态源的默认设置示例:
{
"type": "text",
"id": "featured_product_title",
"label": "Featured product title",
"default": "Featuring: {{ product.title }}"
}
限制
Shopify 限制您在主题不同区域使用的动态源数量。这些限制有助于保持主题的性能。
描述 | 限制 |
JSON 模板中的动态源 | 100 |
一般主题设置中的动态源 | 100 |
分区组中的动态源 | 100 |
单一设置中的动态源 | 50 |
静态分区的动态源 | 50 |
原文链接https://shopify.dev/docs/themes/architecture/settings/dynamic-sources
发表回复