入口蓝图是用于定义您网站区域的标准内容结构。内容结构和入口可以通过不同的方式进行组织,正如我们在此处更详细地描述的那样。
entry 类型支持多个条目并且应在没有其他变体适用时使用。
handle: Team\Member
type: entry
name: Team Member
fields:
name:
label: First Name
type: text以下属性由入口蓝图支持。
| Property | Description |
|---|---|
| handle | A meaningful and unique code to identify the entry. |
| type | The blueprint type which can be a variant of entry, single, structure or stream. |
| name | The label to display when working with this entry. |
| fields | form fields belonging to the group, see backend form fields. |
| groups | references a group of form fields placing the entry in group mode (see below). |
| structure | structure configuration supplied when using the structure type. |
| drafts | enables drafts for this entry. Default: false |
| softDeletes | enables soft deletion for this entry. Default: true |
| multisite | enables multisite for this entry, sync records between group, locale or all sites. Supported values: true, false, sync, locale, all. Default: false |
| pagefinder | includes blueprint type in the pagefinder form widget, supported values: true, false, item, list or array (see below). Default: true |
| defaultSort | used by the entry and stream types, sets a default sorting column and direction when user preference is not defined. Supports a string or an array with keys column and direction. The direction can be asc for ascending (default) or desc for descending order. |
| customMessages | customize the messages used in the user interface (see below). |
| showExport | displays a toolbar button for exporting records. Default: true. |
| showImport | displays a toolbar button for importing records. Default: true. |
| modelClass | replaces the PHP model class with a custom model instance. |
尽管条目类型没有特定的行为,但也有几种可用于组织内容的变体。以下类型是条目的变体。
single 类型将强制每个分区定义只包含一个条目。这适用于一次性内容,例如首页或“联系我们”页面。下面定义了一个 Homepage 分区,其中包含一个欢迎消息 (welcome_message) 文本字段。
handle: Homepage
type: single
name: Homepage Content
fields:
welcome_message:
label: Welcome Message
type: textstructure 类型允许存在多个结构化条目,从而允许存在父子关系. 这对于嵌套内容非常有用,例如文档部分. structure 类型的条目可排序. 它们的排序顺序可以通过在列表视图中拖动它们来调整. 以下定义了一个 文档 树部分,其中包含一个文章内容 (article_content) Markdown 字段.
handle: Docs\Article
type: structure
name: Documentation Article
fields:
content:
label: Article Content
type: markdown默认情况下,结构支持无限嵌套,但是,您可以在 structure 属性中使用 maxDepth 为树指定最大深度。在下一个示例中,只能有一个顶层和一个第二层。
# ...
type: structure
structure:
maxDepth: 2
# ...structure 属性支持以下值。
| Property | Description |
|---|---|
| maxDepth | Maximum depth for the structure. Default: 0 for unlimited. |
| treeExpanded | if tree nodes should be expanded by default. Default: true |
| showReorder | displays an interface for reordering records. Default: true |
| showSorting | allows sorting records, disables the structure when sorted. Default: true |
stream 类型用于基于时间的数据条目,这些条目通常按时间顺序排列。这对于发布近期活动很有用,例如博客部分。下面定义了一个博客订阅源部分,其中包含一个文章内容(content)富文本编辑器字段。
handle: Blog\Post
type: stream
name: Blog Post
fields:
content:
label: Post Content
type: richeditordefaultSort 属性用于设置当蓝图记录以列表形式显示时的默认排序列。这将默认设置为发布日期。
handle: Blog\Post
type: stream
name: Blog Post
defaultSort:
column: title
direction: asc所有条目都可选支持为一个版块定义多个内容组。例如,一个博客版块可能有一个常规文章和一个特色文章,而这些是两个条目组。
条目组由分区蓝图文件中的 groups 属性定义,并且可以为每种类型指定不同的字段。选定的组值在记录上可用作 content_group 属性。
handle: Blog\Post
type: stream
name: Blog Post
groups:
regular_post:
name: Regular Post
fields:
# ...
featured_post:
name: Featured Post
fields:
# ...建议使用 mixin 蓝图 来分组常见的字段定义。
:::
指定 customMessages 属性,以覆盖界面使用的默认消息。这些值可以是纯文本,也可以引用 本地化字符串。
customMessages:
buttonCreate: Create New Event以下消息可覆盖为自定义消息。
::: details 查看可用消息列表
| Message | Default Message |
|---|---|
| buttonCreate | Create :name Entry |
| titleIndexList | Manage :name Entries |
| titleCreateForm | Create :name |
| titleUpdateForm | Update :name |
| pagefinderItemType | :name Entry |
| pagefinderListType | All :name Entries |
| ::: |
条目记录将要求 title 和 slug 字段在保存前填充,此外,slug 字段也必须是唯一的。您可以通过在蓝图中覆盖这些字段来修改此功能。通过将 validation 属性设置为 false 或将 hidden 属性设置为 true 并将其从用户界面中隐藏。以下示例将禁用这两个字段的验证并隐藏 slug 字段。
fields:
title:
validation: false
slug:
hidden: true默认情况下,所有条目都包含在 页面查找器 查找值中。可以通过将 pagefinder 设置为 false 来禁用此功能。
pagefinder: false你可以限制页面查找器上下文,使其只允许将页面定位为单个 项(例如,博客文章)或 列表 的项(例如,所有博客文章),或当设置为 all 时将同时显示两者。
pagefinder: item
pagefinder: list页面查找器将自动解析 id、code、slug 和 fullslug 属性并将它们用作 页面 URL 参数 中的替换项。 您可以指定自定义的 替换项 作为数组,使用 pagefinder 属性,包括可选的 context 如上所述。
pagefinder:
context: list
replacements: []每个替换键应与一个 URL 参数名匹配,并使用点表示法路径来指向属性值。以下是一个博客文章页面的 URL 示例。
url = "/blog/post/:author/:category/:slug/:id"以下替换会将:author参数设置为相关作者的 slug 属性值,并将:category参数设置为第一个相关分类的 slug 属性值。
pagefinder:
replacements:
author: author.slug
category: categories.0.slug全局配置用于定义您网站的全局可用内容。这些字段值经常用于 CMS 布局 并包含设置,例如社交网络链接。
这定义了一个 页脚配置 全局,包含一个 Facebook 链接 (facebook_link) 文本字段。
handle: Site\Footer
type: global
name: Footer Config
fields:
facebook_link:
label: Facebook Link
type: text全局蓝图支持以下属性。
| Property | Description |
|---|---|
| handle | A meaningful and unique code to identify the entry. |
| name | The label to display when working with this entry. |
| fields | form fields belonging to the group, see backend form fields. |
| multisite | enables multisite for this entry, supported values: true, false. Default: false |
| formSize | the settings form size, supported values: tiny, small, medium, large, huge, giant, adaptive. Default: huge. |
混入是字段组,用于在定义内容结构时避免重复。例如,一个位置字段可能会在多个地方使用,然而我们可以通过混入定义将其只定义一次。
以下定义了一个包含国家 (country_code) 和州 (state_code) 文本字段的 Location 集合。
handle: Fields\Location
type: mixin
name: Location
fields:
country_code:
label: Country
type: text
state_code:
label: State
type: text混入蓝图支持以下属性。
| Property | Description |
|---|---|
| handle | A meaningful and unique code to identify the entry. |
| name | The label to display when working with this entry. |
| fields | form fields belonging to the group, see backend form fields. |
考虑为mixin文件和字段名添加下划线 (_) 前缀,以便于查找蓝图类型。例如:
_location_fields.yaml
要在您的条目中包含这些字段,与其他表单字段一样,使用 type 为 mixin 并在 source 属性中引用 UUID 或句柄。
_location_fields:
type: mixin
source: Fields\Location请参阅 Mixin 字段 以获取有关使用 mixin 的更多信息。