Skip to main content

内容类型构建器

🌐 Content-type Builder

Page summary:

内容类型构建器是用于设计内容类型和组件的工具。本指南概述了内容类型构建器,并涵盖字段选项、关联关系、组件使用,以及分享数据建模技巧。

在 内容类型构建器中,用户可以创建和编辑他们的内容类型,该构建器可通过管理面板的主导航访问。

IDENTITY CARD
角色与权限
在“角色 > 插件 - 内容类型构建器”中最低“读取”权限。
环境
仅在开发环境中可用。

概览​

🌐 Overview

The 内容类型构建器允许创建和管理内容类型,这些内容类型可以是:

  • 集合类型:可以管理多个条目的内容类型。
  • 单一类型:只能管理一个条目的内容类型。
  • 组件:可用于多种集合类型和单一类型的内容结构。尽管它们从技术上讲不是正真的内容类型,因为它们不能独立存在,但组件也是通过内容类型构建器创建和管理的,与集合类型和单一类型的方式相同。

所有三者都显示为 内容类型构建器子导航中的类别。在每个类别中列出了所有已创建的内容类型和组件。

集合类型和单一类型也可以分组到文件夹,以便在项目增长时保持子导航的整洁。

🌐 Collection types and single types can also be grouped into folders, to keep the sub navigation organized as a project grows.

Tip

点击 内容类型构建器子导航中的搜索图标 以查找特定的集合类型、单一类型或组件。

在内容类型构建器的子导航中,还显示了一个集中式的 保存 按钮,适用于所有内容类型和组件。随着内容类型/组件和字段状态的显示,这使你可以同时处理多个内容类型和组件。可以显示以下状态:

🌐 In the Content-type Builder's sub navigation is also displayed a centralised Save button that applies for all content-types and components. Along with the display of statuses for both content-types/components and fields, this allows you to work on several content-types and components at the same time. The following statuses can be displayed:

  • New 或 N 表示某个内容类型/组件或字段是新的,尚未保存,
  • Modified 或 M 表示自上次保存以来内容类型/组件或字段已被修改,
  • Deleted 或 D 表示某个内容类型/组件或字段已被删除,但只有在保存后才会得到确认。
Note

点击 保存 按钮旁边的 … 按钮可以访问其他选项,例如 撤销/重做上一次更改 和 放弃所有更改。这些选项也是集中化的,这意味着它们适用于自上次保存以来在所有内容类型、组件和字段上所做的最后操作。

🌐 Clicking on the ... button next to Save gives access to other options, such as Undo/Redo last change and Discard all changes. These options are also centralised, meaning that they apply to the last action(s) that was/were done on all content-types, components and fields since the last time you saved.

配置​

🌐 Configuration

内容类型构建器使用起来无需配置。不过,用于组织内容类型的文件夹会存储在一个专门的文件中,可以直接编辑。

🌐 The Content-type Builder requires no configuration to be used. The folders used to organize content-types are however stored in a dedicated file, which can be edited directly.

基于代码的配置​

🌐 Code-based configuration

在内容类型构建器子导航中显示的文件夹(见 使用文件夹组织内容类型)存储在 src/content-structure/groups.json 文件中。

🌐 The folders displayed in the Content-type Builder sub navigation (see Organizing content-types with folders) are stored in the src/content-structure/groups.json file.

这个文件会随着你项目的其余部分进行版本控制,所以本地定义的组织结构会与团队共享,并随你的应用部署。

🌐 The file is versioned with the rest of your project, so the organization defined locally is shared with your team and deployed with your application.

因此,文件夹的组织会跟随你的项目代码:部署文件可以把它从一个环境移到另一个环境。

🌐 Folder organization therefore travels with your project's code: deploy the file to move it from one environment to another.

Note

数据传输 导出、导入和传输数据库内容和媒体,而不是项目源文件,所以它从不包含 groups.json。传输完成后,目标项目会保留其自身 groups.json 中定义的文件夹。要在两边都拥有相同的文件夹,请部署带有你代码的文件。

文件中的文件夹被称为 groups,并按章节列出,即 collectionTypes 和 singleTypes。每个组都有一个标识符、名称、父级和子级列表:

🌐 Folders are called groups in the file, and are listed per section, collectionTypes and singleTypes. Each group has an identifier, a name, a parent, and a list of children:

/src/content-structure/groups.json
{
"version": 1,
"sections": {
"collectionTypes": {
"groups": [
{
"id": "grp_x8k2m4p7q1",
"name": "Restaurants",
"parent": null,
"children": [{ "type": "group", "id": "grp_c3v9n5t2w6" }]
},
{
"id": "grp_c3v9n5t2w6",
"name": "Menus",
"parent": "grp_x8k2m4p7q1",
"children": [{ "type": "contentType", "uid": "api::menu.menu" }]
}
]
},
"singleTypes": {
"groups": []
}
}
}

以下属性可用:

🌐 The following properties are available:

属性描述
version文件格式的版本。唯一支持的值是 1。
id文件夹的标识符:任何非空字符串,在两个部分中必须唯一。内容类型构建器会生成以 grp_ 为前缀的标识符,手写的标识符如 products 也是有效的。
name文件夹名称,长度为 1 到 255 个字符,不能有前后空格。共享同一父文件夹的两个文件夹名称必须不同,不论大小写。
parent父文件夹的标识符,或者对于位于其部分根目录的文件夹使用 null。
children文件夹包含的内容类型和子文件夹的有序列表。内容类型通过其 uid 引用,文件夹通过其 id 引用。

文件夹最多可以嵌套三层,而且一个内容类型只能属于一个文件夹。

🌐 Folders can be nested up to 3 levels deep, and a content-type can only belong to one folder.

手动编辑文件:Strapi 会读取什么,以及它如何处理无效文件

在构建时,文件会被编译成 dist/src/content-structure/groups.json,这个编译好的版本就是 Strapi 启动服务器时读取的。

🌐 At build time, the file is compiled to dist/src/content-structure/groups.json, and this built version is the one Strapi reads when the server starts.

编辑源文件,不要编辑 dist 里的文件,因为它会在下一次构建时被替换。手动编辑的文件只有在应用重建并重启后才会生效。

🌐 Edit the source file, never the one in dist, which is replaced by the next build. A file edited by hand is taken into account once the application has been rebuilt and restarted.

无法使用的条目在启动时会被修复或忽略,并且会记录一条以 [content-structure] 为前缀的消息。例如:

🌐 Entries that cannot be used are repaired or ignored at startup, and a message prefixed with [content-structure] is logged. For instance:

  • 对一个不再存在的内容类型的引用会从它的文件夹中被删除,
  • 父文件夹缺失的文件夹会被移回其分区的根目录。

如果文件本身无法读取,服务器将不带任何文件夹启动。

🌐 If the file itself cannot be read, the server starts without any folder.

从内容类型构建器保存比在启动时读取文件更严格:如果结构违反了上述规则之一,会被拒绝而不是修复。在构建和部署之前,确保手写的文件符合这些规则。

🌐 Saving from the Content-type Builder is stricter than reading the file at startup: a structure that breaks one of the rules above is rejected instead of being repaired. Make sure a hand-written file follows these rules before building and deploying it.

Note

组件不是内容结构文件的一部分,无法整理到文件夹里。

🌐 Components are not part of the content structure file, and cannot be organized into folders.

使用​

🌐 Usage


创建内容类型​

🌐 Creating content-types

内容类型创建器允许你创建新的内容类型:单一类型和集合类型,同时也可以创建组件。

🌐 The Content-type Builder allows you to create new content-types: single and collection types, but also components.

使用 Strapi AI 创建内容类型 NewThis content is new.​

🌐 Creating content-types with Strapi AI NewThis content is new.

GrowthThis feature is available with a Growth plan.

启用 后,Strapi AI 会添加一个助手,帮助你使用自然语言创建或编辑内容类型。该助手仅适用于 Strapi 管理的 AI:自带 AI 密钥插件 并不能启用它。

要在内容类型构建器中使用 Strapi AI,请点击管理面板右下角的 按钮,并描述你需要的内容:

Strapi AI in Content-Type BuilderStrapi AI in Content-Type Builder

你还可以使用聊天窗口底部的 按钮,从现有的 Strapi 或前端应用导入代码,导入 Figma 项目,或附加图片以从设计中提取内容结构。

Tip

你的提示越精确,你创建的模式就越准确。

🌐 The more precise your prompts, the more accurate your created schemas are likely to be.

例如,以下提示示例在创建关系时效果很好:Could you please generate a collection of dogs then also generate an owner collection and add relationship to dogs? An owner can have multiple dogs, but a dog can only have one owner.

AI credits

Strapi 管理的 AI 在 Growth 计划中每月包含 1,000 个积分,免费试用期间还可获得 10 个免费积分。在 Enterprise 计划中,Strapi AI 由你自己的 AI 提供商驱动,通过 自带 AI 密钥插件,你的提供商会对请求进行计费。

轻量级操作使用较少的积分,而更复杂的操作使用更多。

🌐 Lightweight actions use fewer credits, while more complex ones use more.

你可以在管理面板的 Settings Overview 中查看你的信用使用情况。当你的使用量达到每月配额的80%、90%和100%时,会发送通知。超额使用将产生额外费用。

积分在同一项目实例的所有用户之间共享。

🌐 Credits are shared across all users within the same project instance.

当你的积分用完后,你仍然可以继续使用 Strapi 管理的 AI,超出部分将按月计费。有关 Strapi AI 的更多信息,请参考专门的支持文章。

🌐 When your credits run out, you can keep using Strapi-managed AI, with overages billed monthly. For more information about Strapi AI, please refer to the dedicated support article.

手动创建内容类型​

🌐 Creating content-types manually

Content-type creationContent-type creation
  1. 选择是要创建集合类型还是单一类型。
  2. 在 内容类型构建器的你想要创建的内容类型类别中,点击 创建新集合/单一类型。
  3. 在内容类型创建窗口中,在显示名称文本框中输入新内容类型的名称。
  4. 检查一下 API ID,确保自动填写的值是正确的。在内容管理器中,集合类型的名称确实会自动变为复数形式。建议使用单数名称,但 API ID 字段可以让你纠正任何复数化错误。
  5. (可选)在“选择一个文件夹或输入一个值以创建新文件夹”字段中,选择要显示内容类型的文件夹,或者输入一个名称以创建新文件夹(参见使用文件夹组织内容类型)。
  6. (可选)在高级设置标签中,为新内容类型配置可用设置:
设置名称说明
草稿与发布勾选此复选框以允许内容类型的条目在发布之前以草稿版本进行管理(参见 草稿与发布)。
国际化勾选此复选框以允许内容类型的条目被翻译为其他地区版本。
  1. 点击 继续 按钮。
  2. 为你的内容类型添加并配置所选字段(见 为内容类型配置字段)。
  3. 点击 保存 按钮。
Caution

新的内容类型只有在保存后才被视为已创建。只有在至少添加了一个字段并正确配置后,才能保存。如果未完成这些步骤,则无法创建内容类型,也无法在内容类型构建器中将其列在所属类别中,也无法在 内容管理器 中使用。

🌐 New content-types are only considered created once they have been saved. Saving is only possible if at least one field has been added and properly configured. If these steps have not been done, a content-type cannot be created, listed in its category in the Content-type Builder, and cannot be used in the Content Manager.

新组件​

🌐 New component

Component creationComponent creation
  1. 在 内容类型构建器子导航的组件类别中,点击 创建新组件。
  2. 在组件创建窗口中,配置新组件的基本设置:
    • 在显示名称文本框中输入组件名称。
    • 选择一个可用类别,或在文本框中输入新类别名称来创建类别。
    • (可选) 选择一个代表新组件的图标。你可以使用搜索 来查找图标,而不是滚动浏览列表。
  3. 点击 继续 按钮。
  4. 为你的组件添加并配置所选字段(参见 为内容类型配置字段)。
  5. 点击 保存 按钮。

编辑内容类型​

🌐 Editing content-types

内容类型构建器允许你管理所有现有的内容类型。对于选中的内容类型或组件进行编辑时,内容类型构建器界面的右侧会显示所有可用的编辑和管理选项。

🌐 The Content-type Builder allows you to manage all existing content-types. For a chosen content-type or component to edit, the right side of the Content-type Builder interface displays all available editing and management options.

Content-type Builder's edition interfaceContent-type Builder's edition interface

设置​

🌐 Settings

  1. 点击你的内容类型的 编辑按钮以访问其设置。
  2. 编辑你选择的可用设置:
Content-type Builder's basic settingsContent-type Builder's basic settings
  • 显示名称:内容类型或组件在管理面板中显示的名称。
  • API ID(单数):内容类型或组件在 API 中使用的名称。它是由显示名称自动生成的,但可以编辑。
  • API ID(复数):内容类型或组件在 API 中使用的复数名称。它是从显示名称自动生成的,但可以进行编辑。
  • 类型:内容类型或组件的类型。它可以是集合类型或单一类型。
  1. 在对话框中点击 完成 按钮。
  2. 在内容类型构建器导航中点击保存按钮。

字段​

🌐 Fields

从列出内容类型字段的表格中,你可以:

🌐 From the table that lists the fields of your content-type, you can:

  • 点击 按钮以访问字段的基本和高级设置并进行编辑
  • 点击 添加另一个字段 按钮,为所选内容类型创建新字段
  • 点击 按钮,然后拖放任意字段以重新排序内容类型的字段
  • 点击 按钮以删除字段
Note

自从 5.57.0以来,编辑字段可以在不丢失数据的情况下重命名它:当你保存更改时,Strapi 会要求你确认重命名,然后通过重命名底层数据库列而不是重新创建它来保留字段的现有数据。相同的重命名操作也可以通过命令行使用 strapi rename:field 完成。

Caution

当一个字段被重命名并且同时更改其类型、关系或组件时,数据无法保留:字段会像以前一样被重新创建为空。

🌐 Data cannot be preserved when a field is renamed and its type, relation, or component is changed at the same time: the field is recreated empty, as before.

重命名内容类型或组件,也就是编辑它的 API ID,目前还不支持:像以前一样,这会创建一个新的数据库表,而且与原表相关的数据在你应用的管理面板中将无法访问。

🌐 Renaming a content-type or a component, that is, editing its API ID, is not covered yet: as before, this creates a new database table, and the data associated with the former table is not accessible from the admin panel of your application anymore.

配置内容类型字段​

🌐 Configuring content-types fields

内容类型由一个或多个字段组成。每个字段旨在包含特定类型的数据,这些数据在内容管理器中填写(参见 创建与编写内容)。

🌐 Content-types are composed of one or several fields. Each field is designed to contain specific kind of data, filled up in the Content Manager (see Creating & Writing content).

在 内容类型构建器中,可以在创建新的内容类型或组件时添加字段,也可以在编辑或更新内容类型或组件时添加字段。

Note

根据创建或编辑的内容类型或组件,并非所有字段(包括组件和动态区域)始终可用。

🌐 Depending on what content-type or component is being created or edited, not all fields -including components and dynamic zones- are always available.

Private fields and search

当你把一个字段标记为私有字段时,新建的私有字段会自动设置为不可搜索(searchable: false)。这样可以防止私有内容在使用 _q 搜索参数时出现在查询结果中。已有的私有字段会保留当前的可搜索设置,除非你明确修改它们。如果你需要让私有字段可搜索,可以在字段的高级设置中启用它。

🌐 When you mark a field as Private field, newly created private fields are automatically set to be non-searchable (searchable: false). This prevents private content from appearing in query results when using the _q search parameter. Existing private fields retain their current searchability settings unless you explicitly change them. If you need a private field to be searchable, you can enable it in the field's advanced settings.

Fields selectionFields selection

文本​

文本字段显示一个可以包含小文本的文本框。该字段可用于标题、描述等。

🌐 The Text field displays a textbox that can contain small text. This field can be used for titles, descriptions, etc.

设置名称说明
名称填写文本字段的名称。
类型在 短文本(最多255个字符) 和 长文本之间选择,以提供更多或更少的空间填写文本字段。

富文本(块)​

富文本(块)字段显示一个带有实时渲染和各种选项的编辑器,用于管理富文本。此字段可用于较长的书面内容,甚至包括图片和代码。

🌐 The Rich Text (Blocks) field displays an editor with live rendering and various options to manage rich text. This field can be used for long written content, even including images and code.

设置名称使用说明
名称写入富文本(区块)字段的名称。
React renderer

如果使用积木编辑器,我们建议你也使用 Strapi Blocks React Renderer 来轻松地在 React 前端渲染内容。

编号​

数字字段显示一个可用于任何类型数字的字段:整数、小数和浮点数。

🌐 The Number field displays a field for any kind of number: integer, decimal and float.

设置名称说明
名称写下数字字段的名称。
数字格式在 整数、大整数、小数 和 浮点数 之间选择。

日期​

日期字段可以显示日期(年、月、日)、时间(时、分、秒)或日期时间(年、月、日、时、分、秒)选择器。

🌐 The Date field can display a date (year, month, day), time (hour, minute, second) or datetime (year, month, day, hour, minute, and second) picker.

设置名称说明
名称填写日期字段的名称。
类型在 date、datetime 和 time 之间选择

密码​

密码字段显示已加密的密码字段。

🌐 The Password field displays a password field that is encrypted.

设置名称说明
名称写下密码字段的名称。

媒体​

媒体字段允许你从应用的媒体库中选择一个或多个媒体文件(例如图片、视频)。

🌐 The Media field allows you to choose one or more media files (e.g. image, video) from those uploaded in the Media Library of the application.

设置名称说明
名称撰写媒体字段的名称。
类型在 多媒体(允许上传多个媒体)和 单一媒体(只允许上传一个媒体)之间选择。

关系​

关联字段让你可以与另一个内容类型建立关联,该内容类型必须是集合类型。

🌐 The Relation field allows you to establish a relation with another content-type, that must be a collection type.

有 6 种不同类型的关系:

🌐 There are 6 different types of relations:

  • 一种方式:内容类型A 有一个 内容类型B
  • 一对一:内容类型 A 有并属于一个 内容类型 B
  • 一对多:内容类型 A 属于多个 内容类型 B
  • 多对一:内容类型 B 拥有多个 内容类型 A
  • 多对多:内容类型 A 拥有并属于多个 内容类型 B
  • 多种方式:内容类型 A 有多种 内容类型 B
Multi relations and single relations

至少有一方可以引用多个条目的关系称为多重关系。在内容类型构建器中,这包括一对多、多对一、多对多和多向关系。这些关系在内容管理器中显示为多选字段,并且从 REST、GraphQL 和文档服务 API 返回数组;而单一关系(一向和一对一关系)返回单个关联条目(有关更多信息,请参见 使用 API 请求管理关系)。

🌐 Relations where at least one side can reference several entries are called multi relations. In the Content-type Builder, this includes one-to-many, many-to-one, many-to-many, and many-way relations. These relations appear as multi-select fields in the Content Manager and return arrays from the REST, GraphQL, and Document Service APIs; while single relations (one-way and one-to-one relations) return a single linked entry (see Managing relations with API requests for more information).

配置关系字段的基本设置包括选择应与哪个现有内容类型建立关系以及关系的类型。关系字段的编辑窗口显示两个灰色框,每个框代表一个相关内容类型。在灰色框之间显示所有可能的关系类型。

🌐 Configuring the basic settings of the Relation field consists in choosing with which existing content-type the relation should be established and the kind of relation. The edition window of the Relation field displays 2 grey boxes, each representing one of the content-types in relation. Between the grey boxes are displayed all possible relation types.

  1. 点击第二个灰色框以定义内容类型 B。它必须是已创建的集合类型。
  2. 单击代表要在内容类型之间建立的关系的图标。
  3. 选择内容类型 A 的字段名称,即将在内容类型 A 中用于该字段的名称。
  4. (如果关系类型禁用,则可选) 选择内容类型 B 的 字段名称。
Modeling nested page hierarchies

要对可导航的页面树进行建模:

🌐 To model a navigable tree of pages:

  1. 添加一个 Page 集合类型,并包含一个“Slug”(UID)字段,以及一个可选的“Order”(整数)字段来控制同级排序。
  2. 从 Page 到 Page 创建一个关联字段,并选择 多对一,这样每个页面都可以设置它的“父页面”。Strapi 会自动提供反向的“子页面”关联。
  3. 在读取数据时,递归地填充 children 以加载树。保持递归深度较小以避免响应过大。
示例
Populate nested children for a page tree
{
populate: {
children: {
fields: ['title', 'slug'],
populate: {
children: {
fields: ['title', 'slug'],
},
},
},
},
}

相同的填充模式适用于 GraphQL 或文档服务 API(参见 理解填充指南)。

🌐 The same populate pattern works with GraphQL or the Document Service API (see Understanding populate guide).

布尔​

布尔字段显示一个切换按钮来管理布尔值(例如是或否、1 或 0、True 或 False)。

🌐 The Boolean field displays a toggle button to manage boolean values (e.g. Yes or No, 1 or 0, True or False).

设置名称说明
名称填写布尔字段的名称。

JSON​

这个 JSON 字段允许你以 JSON 格式配置数据,用来存储 JSON 对象或数组。

🌐 The JSON field allows you to configure data in a JSON format, to store JSON objects or arrays.

设置名称说明
名称写下 JSON 字段的名称

电子邮件​

电子邮件字段显示带有格式验证的电子邮件地址字段,以确保电子邮件地址有效。

🌐 The Email field displays an email address field with format validation to ensure the email address is valid.

设置名称说明
名称填写电子邮件字段的名称。

密码​

密码字段显示已加密的密码字段。

🌐 The Password field displays a password field that is encrypted.

设置名称说明
名称写下密码字段的名称。

枚举​

枚举字段允许你配置一个在下拉列表中显示的值列表。

🌐 The Enumeration field allows you to configure a list of values displayed in a drop-down list.

设置名称说明
名称写下枚举字段的名称。
值写下枚举的值,每行一个。
Caution

枚举值应始终在任何数字前有一个字母字符,否则在安装 GraphQL 插件时可能会导致服务器崩溃而不另行通知。

🌐 Enumeration values should always have an alphabetical character preceding any number as it could otherwise cause the server to crash without notice when the GraphQL plugin is installed.

UID​

UID 字段显示设置唯一标识符的字段,可以选择基于相同内容类型的现有其他字段。

🌐 The UID field displays a field that sets a unique identifier, optionally based on an existing other field from the same content-type.

设置名称说明
名称输入 UID 字段的名称。名称中不得包含特殊字符或空格。
附加字段选择要附加到 UID 字段的现有字段。选择 无 表示不附加任何特定字段。
Tip

UID 字段可用于根据 Attached 字段创建 slug。

🌐 The UID field can be used to create a slug based on the Attached field.

富文本(Markdown)​

富文本(Markdown)字段显示一个带有基本格式选项的编辑器,用于管理以Markdown编写的富文本。此字段可用于较长的书面内容。

🌐 The Rich Text (Markdown) field displays an editor with basic formatting options to manage rich text written in Markdown. This field can be used for long written content.

设置名称使用说明
名称写入富文本(Markdown)字段的名称。

组件​

组件是由多个字段组合而成的。组件允许你创建可重复使用的字段集合,这些集合可以快速添加到内容类型、动态区域,也可以嵌套到其他组件中。

🌐 Components are a combination of several fields. Components allow you to create reusable sets of fields, that can be quickly added to content-types, dynamic zones but also nested into other components.

通过内容类型生成器配置组件时,可以:

🌐 When configuring a component through the Content-type Builder, it is possible to either:

  • 通过点击 创建新组件 来创建一个新组件(参见 创建新组件),
  • 或者点击使用现有组件来使用已有的组件。
设置名称说明
名称为内容类型写入组件名称。
选择组件仅在使用现有组件时 - 从下拉列表中选择一个现有组件。
类型在可重复组件和单组件之间选择:可重复组件允许为内容类型多次使用该组件,单组件限制该组件仅可使用一次。

动态区域​

动态区域是可以添加到内容类型中的组件组合。它们允许灵活的内容结构,因为一旦进入内容管理器,管理员可以根据需要选择如何组合和重新排列动态区域的组件。

🌐 Dynamic zones are a combination of components that can be added to content-types. They allow a flexible content structure as once in the Content Manager, administrators have the choice of composing and rearranging the components of the dynamic zone how they want.

设置名称指令
名称为内容类型写入动态区域的名称。

在配置动态区域的设置之后,其组件也必须进行配置。可以选择现有组件或创建一个新组件。

🌐 After configuring the settings of the dynamic zone, its components must be configured as well. It is possible to either choose an existing component or create a new one.

Caution

使用动态区域时,不同组件不能具有不同类型(或枚举字段、不同值)的相同字段名称。

🌐 When using dynamic zones, different components cannot have the same field name with different types (or with enumeration fields, different values).

自定义字段​

🌐 Custom fields

自定义字段 是通过向内容类型或组件添加新类型字段来扩展 Strapi 功能的一种方式。安装后(参见 Marketplace 文档),在为内容类型选择字段时,自定义字段会列在 自定义 选项卡中。

每种自定义字段类型都可以有基本和高级设置。 Marketplace 列出了可用的自定义字段,并为每个自定义字段提供专门的文档,包括具体设置。

删除内容类型​

🌐 Deleting content-types

内容类型和组件可以通过内容类型构建器删除。删除内容类型会自动删除内容管理器中基于该内容类型的所有条目。组件的删除也是如此,它会自动从使用该组件的所有内容类型或条目中删除。

🌐 Content types and components can be deleted through the Content-type Builder. Deleting a content-type automatically deletes all entries from the Content Manager that were based on that content-type. The same goes for the deletion of a component, which is automatically deleted from every content-type or entry where it was used.

  1. 在 内容类型构建器子导航中,点击要删除的内容类型或组件的名称。
  2. 在所选内容类型或组件的编辑界面中,点击内容类型或组件名称右侧的 编辑按钮。
  3. 在编辑窗口中,点击 删除 按钮。
  4. 在确认窗口中,确认删除。
  5. 在内容类型构建器子导航中点击 保存 按钮。
Caution

删除内容类型只会删除通过内容类型构建器创建的内容,以及由此从你的 Strapi 应用的管理面板中可访问的内容。然而,基于该内容类型创建的所有数据仍会保留在数据库中。有关更多信息,请参阅相关 GitHub issue。

Deletion of content type in Content-type BuilderDeletion of content type in Content-type Builder

用文件夹整理内容类型 NewThis content is new.​

🌐 Organizing content-types with folders NewThis content is new.

集合类型和单一类型可以分组到文件夹中,文件夹可以嵌套最多 3 级。文件夹会显示在 内容类型构建器的子导航中。

它们也会显示在内容管理器中,帮助内容管理员更快地找到内容类型。

🌐 They are also displayed in the Content Manager, where they help content managers find content-types more quickly.

Folders in the Content-type Builder sub navigationFolders in the Content-type Builder sub navigation

文件夹存储在你项目的内容结构文件中。和在内容类型构建器中进行的其他更改一样,文件夹的更改只有在点击保存后才会生效。

🌐 Folders are stored in the content structure file of your project. As for any other change made in the Content-type Builder, folder changes are applied only after clicking Save.

创建文件夹​

🌐 Creating folders

  1. 在 内容类型构建器的子导航中,打开集合类型或单一类型类别的创建菜单,然后点击新建文件夹。
  2. 写下文件夹的名字,然后按 Enter。
  3. 点击 保存 按钮。

文件夹会在它们所属类别的根目录下创建,然后可以移动到另一个文件夹里。

🌐 Folders are created at the root of their category, and can then be moved into another folder.

Note

同一个父文件夹下的两个文件夹不能重名。

移动内容类型和文件夹​

🌐 Moving content-types and folders

内容类型和文件夹可以通过在 内容类型构建器子导航中拖放来移动。

把一个项目拖到文件夹里可以放入其中,把它从文件夹拖出来可以移回类别的根目录,或者上下拖动它来重新排序。

🌐 Drag an item onto a folder to put it inside, drag it out of a folder to take it back to the root of its category, or drag it up and down to reorder it.

一个内容类型一次只能属于一个文件夹,而且文件夹的嵌套最多只能到三级。

🌐 A content-type can only belong to one folder at a time, and the nesting of folders is limited to 3 levels.

一旦内容类型和文件夹按你想要的方式整理好,点击保存按钮。

🌐 Once the content-types and folders are organized as you want, click on the Save button.

重命名文件夹​

🌐 Renaming folders

  1. 在 内容类型构建器子导航中,点击文件夹的 按钮进行重命名。
  2. 点击 重命名。
  3. 输入文件夹的新名称,然后按 Enter。
  4. 点击 保存 按钮。

删除文件夹​

🌐 Deleting folders

  1. 在 内容类型构建器子导航中,点击要删除的文件夹的 按钮。
  2. 点击以下选项之一:
    • 删除文件夹仅删除文件夹。其包含的内容类型和文件夹将会移动到父文件夹,或如果该文件夹没有嵌套,则移动到类别的根目录。
    • 删除文件夹及内容,以删除该文件夹以及其中包含的内容类型和文件夹。只有在文件夹非空时,此选项才可用。
  3. 在确认窗口中,会显示受影响的内容类型和文件夹数量,点击是,删除。
  4. 点击 保存 按钮。

当将子文件夹移出该文件夹会导致目标位置出现两个同名文件夹时(无论大小写如何),删除文件夹是不可用的。

确认窗口会列出冲突的名称,是,删除会保持禁用状态,直到其中一个文件夹被重命名。

🌐 The confirmation window then lists the conflicting names, and Yes, delete stays disabled until one of these folders is renamed.

Caution

删除文件夹及内容 会删除该文件夹、其子文件夹,以及为你的应用创建的内容类型,效果与一个一个删除这些内容类型相同(参见删除内容类型)。

Content-type Builder 不管理的内容类型,比如来自插件的那些,会被保留并移出文件夹,确认窗口会显示有多少被保留下来。

🌐 Content-types that the Content-type Builder does not manage, such as the ones coming from plugins, are kept and moved out of the folders, and the confirmation window indicates how many of them are preserved.

要保留所有内容类型,请改用删除文件夹。

🌐 To keep all the content-types, use Delete folder instead.