在后台区域,条目将列在内容菜单项下,全局项将列在设置菜单项下(默认情况)。您可以使用蓝图文件中的 navigation 属性控制此行为。以下代码将设置一个图标并指定显示顺序。
navigation:
icon: icon-pencil
order: 200以下属性受 navigation 和 primaryNavigation 定义支持。
| Property | Description |
|---|---|
| label | specifies the menu label localization string key, required. |
| order | a numerical weight when determining the display order. |
| parent | links the navigation item to a parent item using a blueprint handle. |
| icon | an icon name from the October CMS icon collection, optional. |
| iconSvg | an SVG icon to be used in place of the standard icon, the SVG icon should be a rectangle and can support colors, optional. |
要在“设置”区域放置一个项目,请将 parent 设置为 settings。category 定义可以是一个字符串,也可以是一个设置常量引用,例如. CATEGORY_COLLECTIONS。
navigation:
parent: settings
category: Collections要在内容区域放置一个项目,将 父级 设置为 content。
navigation:
parent: content要将该项目作为主导航项。需要一个 primaryNavigation 定义。
primaryNavigation:
label: Blog
icon: icon-copy
order: 500
navigation:
label: Main Menu Item将该项作为二级导航项放置。该 parent 属性应指定某个主导航项的 UUID 或句柄。
navigation:
parent: <handle|uuid>要禁用次级导航,请为单个蓝图定义 primaryNavigation,而不将其作为任何其他蓝图的父级。
primaryNavigation:
label: Page
icon: icon-magic
order: 500您也可以通过将 navigation 属性设置为 false 来完全禁用导航。
navigation: false使用 extraNavigation 属性注册自定义导航项以包含在蓝图中。该值是一个数组,与 [后端导航规范](../../extend/backend/navigation.md) 中找到的 sideMenu 定义相匹配。以下示例包含两个部分和分隔符,使用自定义显示类型,其中 order 属性用于按正确顺序排列这些项。
navigation:
label: Authors
parent: Blog\Post
icon: icon-user
order: 230
extraNavigation:
_authors_section:
itemType: section
label: Authors
order: 210
_authors_ruler:
itemType: ruler
order: 220您还可以注册链接到 插件引入的控制器 通过指定 url 属性。此属性应设置为控制器 URL,如下链接到 acme/blog/posts 控制器。
navigation:
label: Authors
# ...
extraNavigation:
testimonials:
label: Testimonials
order: 210
icon: icon-group
url: acme/blog/posts要在控制器内部设置导航上下文,请使用 BackendMenu 门面上的 setTailorContext 方法。您还可以通过 setTailorContextUuid 方法指定蓝图 uuid。该方法接受蓝图的 handle 或 uuid (第一个参数),以及额外导航项使用的键(第二个参数)。
BackendMenu::setTailorContext('Blog\Post', 'testimonials');
BackendMenu::setTailorContextUuid('edcd102e-0525-4e4d-b07e-633ae6c18db6', 'testimonials');