Skip to content

Custom Settings (OrchardCore.CustomSettings)

自定义设置(OrchardCore.CustomSettings)

Usage

用法

Custom Settings allows a site administrator to create a customized set of properties that are global to the web sites. These settings are

自定义设置允许站点管理员创建一组自定义的属性,这些属性对于网站是全局的。这些设置是

edited in the standard Settings section and can be protected with specific permissions.

在标准设置部分编辑,可以使用特定权限进行保护。

Creating Custom Settings

创建自定义设置

Custom Settings are organized in sections. Each section is represented by a Content Type with the CustomSettings stereotype.

自定义设置按部分组织。每个部分由具有“CustomSettings”构造型的内容类型表示。

When creating such a section, remember to disable Creatable, Listable, Draftable and Securable metadata as they don't apply.

在创建这样的部分时,请记住禁用CreatableListableDraftableSecurable元数据,因为它们不适用。

Warning

!警告

Don't mark any existing Content Type with this `CustomSettings` stereotype, as this will break existing content items of this type.

Custom Settings are then comprised of parts and fields like any other content type.

然后,自定义设置由与任何其他内容类型相似的部分和字段组成。

Once created, open the Setting menu item and each of these sections should appear alongside the module-provided ones.

创建后,打开“设置”菜单项,每个部分都应与模块提供的部分一起显示。

Permissions

权限

Each Custom Settings sections gets a dedicated permission to allow specific users to edit them.

每个“自定义设置”部分都获得专用权限,允许特定用户编辑它们。

To edit this permission open the Roles editor and go to the OrchardCore.CustomSettings Feature group.

要编辑此权限,请打开角色编辑器并转到OrchardCore.CustomSettings功能组。

Templates

模板

The Custom Settings like other settings are available in the {{ Site.Properties }} object.

自定义设置与其他设置一样可在{{Site.Properties}}对象中找到。

Each section is made available using its name.

每个部分都使用其名称。

For instance the HtmlBodyPart of a custom settings section named BlogSettings would be accessible using {{ Site.Properties.BlogSettings.HtmlBodyPart }}.

例如,可以使用{{Site.Properties.BlogSettings.HtmlBodyPart}}访问名为BlogSettings的自定义设置部分的HtmlBodyPart