区域
<section>
— 标记引用了系统配置中的现有节或新节。
章节属性参考
<section>
— 标记可以具有以下属性:
属性 | 描述 | 类型 | 必填 |
---|---|---|---|
id | 定义用于引用部分的标识符。 | typeId | 必填 |
translate | 定义应可翻译的字段。 提供label 以使标签可翻译。 | string | 可选 |
type | 定义渲染的HTML元素的输入类型。 默认为text 。 | string | 可选 |
sortOrder | 定义部分的排序顺序。 高数字会将部分推到页面底部;低数字会将部分推到页面顶部。 | float | 可选 |
showInDefault | 定义节是否显示在默认配置范围内。 指定1 显示节,指定0 隐藏节。 | int | 可选 |
showInStore | 定义节是否显示在存储级别。 指定1 显示节,指定0 隐藏节。 | int | 可选 |
showInWebsite | 定义是否在网站级别显示部分。 指定1 显示节,指定0 隐藏节。 | int | 可选 |
canRestore | 定义能否将部分还原为默认值。 | int | 可选 |
advanced | 自100.0.2起已弃用。 | bool | 可选 |
extends | 通过提供另一部分的标识符,此节点的内容将扩展您引用的部分。 | string | 可选 |
节节点引用
<section>
— 标记可以具有以下子项:
节点 | 描述 | 类型 |
---|---|---|
label | 定义在前端中显示的标签。 | string |
class | 将定义的CSS类添加到渲染的节HTML元素。 | string |
tab | 引用关联的选项卡。 需要选项卡的ID。 | typeTabId |
header_css | 在编写本报告时既未使用也未评估。 | string |
resource | 引用ACL资源以提供此部分的权限设置。 | typeAclResourceId |
group | 定义一个或多个子组。 | typeGroup |
frontend_model | 指定其他前端模型以更改渲染并修改输出。 | typeModel |
include | 用于包含其他system_include.xsd 个兼容文件。 通常用于构造大型system.xml 文件。 | includeType |
示例:创建部分并将其分配给选项卡
以下代码片段演示了创建新部分的基本用法。
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="A_UNIQUE_ID" translate="label" class="a-custom-css-class-to-style-this-tab" sortOrder="10">
<label>A meaningful label</label>
</tab>
<section id="A_UNIQUE_SECTION_ID" showInDefault="1" showInWebsite="0" showInStore="1" sortOrder="10" translate="label">
<label>A meaningful section label</label>
<tab>A_UNIQUE_ID</tab>
<resource>VENDOR_MODULE::path_to_the_acl_resource</resource>
</section>
</system>
</config>
上述部分定义了ID A_UNIQUE_SECTION_ID
,在默认配置视图和存储上下文中可见。 label
节点是可翻译的。 分区与ID为A_UNIQUE_ID
的选项卡相关联。 只有在ACL VENDOR_MODULE::path_to_the_acl_resource
中定义权限的用户才能访问该部分。
组
<group>
— 标记用于将字段组合在一起。
组属性引用
<group>
— 标记可以具有以下属性:
属性 | 描述 | 类型 | 必填 |
---|---|---|---|
id | 定义用于引用组的标识符。 | typeId | 必填 |
translate | 定义应可翻译的字段。 提供label 以使标签可翻译。 多个字段应使用空格分隔。 | string | 可选 |
type | 定义渲染的HTML元素的输入类型。 默认为text 。 | string | 可选 |
sortOrder | 定义部分的排序顺序。 高数字会将部分推到页面底部;低数字会将部分推到页面顶部。 | float | 可选 |
showInDefault | 定义组是否显示在默认配置范围内。 指定1 显示组,指定0 隐藏组。 | int | 可选 |
showInStore | 定义组是否显示在存储级别。 指定1 显示组,指定0 隐藏组。 | int | 可选 |
showInWebsite | 定义是否在网站级别显示组。 指定1 显示组,指定0 隐藏组。 | int | 可选 |
canRestore | 定义是否可以将该组还原为默认值。 | int | 可选 |
advanced | 自100.0.2起已弃用。 | bool | 可选 |
extends | 通过提供另一个组的标识符,此节点的内容将扩展您引用的部分。 | string | 可选 |
组节点引用
<group>
— 标记可以具有以下子项:
节点 | 描述 | 类型 |
---|---|---|
label | 定义在前端中显示的标签。 | string |
fieldset_css | 向组字段集添加一个或多个CSS类。 | string |
frontend_model | 指定其他前端模型以更改渲染并修改输出。 | typeModel |
clone_model | 指定给定模型以克隆字段。 | typeModel |
clone_fields | 启用或禁用了字段的克隆。 | int |
help_url | 不可扩展。 请参阅下文。 | typeUrl |
more_url | 不可扩展。 请参阅下文。 | typeUrl |
demo_link | 不可扩展。 请参阅下文。 | typeUrl |
comment | 在组标签下添加注释。 通过使用<![CDATA[//]]> ,可以应用HTML。 | string |
hide_in_single_store_mode | 该组是否应该在单存储模式下可见。 1 隐藏组;0 显示该组。 | int |
field | 定义此组下应可用的一个或多个字段。 | field |
group | 定义一个或多个子组。 | unbounded |
depends | 可用于声明对其他字段的依赖关系。 仅当给定字段的值为1 时才用于显示特定字段/组。 此节点需要section/group/field 字符串。 | depends |
attribute | 前端模型可以使用自定义属性。 通常用于使给定的前端模型更动态。 | attribute |
include | 用于包含其他system_include.xsd 个兼容文件。 通常用于构造大型system.xml 文件。 | includeType |
节点
more_url
、demo_url
和help_url
由只使用一次的PayPal前端模型定义。 这些节点不可重用。示例:为给定节创建组
以下代码段演示了创建新组的基本用法。
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="A_UNIQUE_ID" translate="label" class="a-custom-css-class-to-style-this-tab" sortOrder="10">
<label>A meaningful label</label>
</tab>
<section id="A_UNIQUE_SECTION_ID" showInDefault="1" showInWebsite="0" showInStore="1" sortOrder="10" translate="label">
<label>A meaningful section label</label>
<tab>A_UNIQUE_ID</tab>
<resource>VENDOR_MODULE::path_to_the_acl_resource</resource>
<group id="A_UNIQUE_GROUP_ID" translate="label comment" sortOrder="10" showInDefault="1" showInWebsite="0" showInStore="1">
<label>A meaningful group label</label>
<comment>An additional comment helping users to understand the effect when configuring the fields defined in this group.</comment>
<!-- Add your fields here. -->
</group>
</section>
</system>
</config>
上述组定义ID A_UNIQUE_GROUP_ID
,在默认配置视图和存储上下文中可见。 label
和comment
都标记为可翻译。