Navigation (OrchardCore.Navigation)
导航(OrchardCore.Navigation)
Purpose
目的
Provides the Navigation
, Pager
and PagerSlim
shapes.
提供Navigation
,Pager
和PagerSlim
形状。
Theming
主题化
Navigation can be themed by adding the appropriate partial view files to your theme's views folder.
可以通过将适当的部分视图文件添加到主题的视图文件夹中来进行导航。
A good example can be found in the TheAdmin theme project.
可以在[TheAdmin主题项目](https://github.com/OrchardCMS/OrchardCore/tree/dev/src/OrchardCore.Themes/TheAdmin)中找到一个很好的例子。
That theme creates the standard, vertical navigation menu that is found on the admin dashboard of any OrchardCore application.
该主题创建了标准的垂直导航菜单,可在任何OrchardCore应用程序的管理仪表板上找到。
The TheAdmin theme provides the following alternates to the default ones provided in the Navigation module:
TheAdmin主题提供以下替代导航模块中提供的默认值:
Navigation-admin.cshtml
NavigationItem-admin.cshtml
NavigationItemLink-admin.cshtml
The theme developer has full control over how and where navigation is displayed on their OrchardCore application.
主题开发人员可以完全控制导航在OrchardCore应用程序中的显示方式和位置。
Pager
呼叫器
This is a multi-purpose pagination component that renders links to specific page numbers.
这是一个多用途分页组件,用于呈现指向特定页码的链接。
It can optionally render First and Last links.
它可以选择呈现_First_和_Last_链接。
| Parameter | Type | Description |
|参数|输入|说明|
| --------- | ---- |------------ |
| --------- | ---- | ------------ |
| Page
| int
| Active page number |
| Page
| int
|活动页码|
| PageSize
| int
| Number of items per page |
| PageSize
| int
|每页的项目数|
| TotalItemCount
| double
| Total number of items (used to calculate the number of the last page) |
| TotalItemCount
| double
|项目总数(用于计算最后一页的编号)|
| Quantity
| int?
| Number of pages to show, 7 if not specified |
| 数量
| int?
|要显示的页数,如果未指定,则为7
| FirstText
| object
| Text of the "First" link, default: T["<<"]
|
| FirstText
| object
| “First”链接的文本,默认:T [“<<”]
|
| PreviousText
| object
| Text of the "Previous" link, default: T["<"]
| PreviousText
| object
| “上一页”链接的文本,默认:T [“<”]
| NextText
| object
| Text of the "Next" link, default: T[">"]
|
| NextText
| object
| “下一步”链接的文本,默认为:T [“>”]
|
| LastText
| object
| Text of the "Last" link, default: T[">>"]
|
| LastText
| object
| “Last”链接的文本,默认为:T [“>>”]
|
| GapText
| object
| Text of the "Gap" element, default: T["..."]
|
| GapText
| object
| “Gap”元素的文本,默认:T [“...”]
|
| PagerId
| string
| An identifier for the pager. Used to create alternate like Pager__[PagerId]
|
| PagerId
| string
|寻呼机的标识符。用于创建像Pager __ [PagerId]`|的替代
| ShowNext
| bool
| If true, the "Next" link is always displayed |
| ShowNext
| bool
|如果为true,则始终显示“Next”链接
Properties inherited from the List
shape
属性从List
形状继承而来
| Parameter | Type | Description |
|参数|输入|说明|
| --------- | ---- |------------ |
| --------- | ---- | ------------ |
| Id
| string
| The HTML id used for the pager, default: none |
| Id
| string
|用于寻呼机的HTML ID,默认值:none |
| Tag
| string
| The HTML tag used for the pager, default: ul
|
| 标签
| string
|用于寻呼机的HTML标签,默认:ul
|
| ItemTag
| string
| The HTML tag used for the pages, default: li
|
| ItemTag
| string
|用于页面的HTML标记,默认为:li
|
| FirstClass
| string
| The HTML class used for the first page, default: first
|
| FirstClass
| string
|用于第一页的HTML类,默认:first
|
| LastClass
| string
| The HTML tag used for last page, default: last
|
| LastClass
| string
|用于最后一页的HTML标记,默认为:last
|
| ItemClasses
| List<string>
| Classes that are assigned to the pages, default: none |
| ItemClasses
| List <string>
|分配给页面的类,默认值:none |
| ItemAttributes
| Dictionary<string, string>
| Attributes that are assigned to the pages |
| ItemAttributes
| Dictionary <string,string>
|分配给页面的属性
The PagerId
property is used to create templates for specific instances. For instance, assigning
PagerId
属性用于为特定实例创建模板。例如,分配
the value MainBlog
to PagerId
and then rendering the pager will look for a template named
将值“MainBlog”改为“PagerId”然后呈现寻呼机将查找名为的模板
Pager-MainBlog.cshtml
.
A pager can be further customized by defining templates for the following shapes:
通过定义以下形状的模板,可以进一步定制寻呼机:
-
Pager_Gap
-
Pager_Gap
-
Pager_First
-
Pager_First
-
Pager_Previous
-
Pager_Previous
-
Pager_Next
-
Pager_Next
-
Pager_Last
-
Pager_Last
-
Pager_CurrentPage
-
Pager_CurrentPage
Each of these shapes are ultimately morphed into Pager_Link
这些形状中的每一个最终都变成了“Pager_Link”
Alternates for each of these shapes are created using the PagerId like Pager_Previous__[PagerId]
which
每个形状的替代都是使用_PagerId_创建的,如Pager_Previous __ [PagerId]
would in turn look for the template Pager-MainBlog.Previous.cshtml
.
反过来会寻找模板Pager-MainBlog.Previous.cshtml
。
PagerSlim
PagerSlim
This shape renders a pager that is comprised of two links: Previous and Next.
此形状呈现由两个链接组成的寻呼机:Previous_和_Next。
| Parameter | Type | Description |
|参数|输入|说明|
| --------- | ---- |------------ |
| --------- | ---- | ------------ |
| PreviousClass
| string
| The HTML class used for the Previous link, default: none |
| PreviousClass
| string
|用于_Previous_链接的HTML类,默认为:none |
| NextClass
| string
| The HTML class used for the Next link, default: none |
| NextClass
| string
|用于_Next_链接的HTML类,默认值为:none |
| PreviousText
| object
| Text of the "Previous" link, default: T["<"]
| PreviousText
| object
| “上一页”链接的文本,默认:T [“<”]
| NextText
| object
| Text of the "Next" link, default: T[">"]
|
| NextText
| object
| “下一步”链接的文本,默认为:T [“>”]
|
Properties inherited from the List
shape
属性从List
形状继承而来
| Parameter | Type | Description |
|参数|输入|说明|
| --------- | ---- |------------ |
| --------- | ---- | ------------ |
| Id
| string
| The HTML id used for the pager, default: none |
| Id
| string
|用于寻呼机的HTML ID,默认值:none |
| Tag
| string
| The HTML tag used for the pager, default: ul
|
| 标签
| string
|用于寻呼机的HTML标签,默认:ul
|
| ItemTag
| string
| The HTML tag used for the pages, default: li
|
| ItemTag
| string
|用于页面的HTML标记,默认为:li
|
| FirstClass
| string
| The HTML class used for the first page, default: first
|
| FirstClass
| string
|用于第一页的HTML类,默认:first
|
| LastClass
| string
| The HTML tag used for last page, default: last
|
| LastClass
| string
|用于最后一页的HTML标记,默认为:last
|
| ItemClasses
| List<string>
| Classes that are assigned to the pages, default: none |
| ItemClasses
| List <string>
|分配给页面的类,默认值:none |
| ItemAttributes
| Dictionary<string, string>
| Attributes that are assigned to the pages |
| ItemAttributes
| Dictionary <string,string>
|分配给页面的属性
A slim pager can be further customized by defining templates for the following shapes:
通过定义以下形状的模板,可以进一步定制超薄寻呼机:
-
Pager_Previous
-
Pager_Previous
-
Pager_Next
-
Pager_Next
Examples of Liquid alternates or templates for Pager_Next
and Pager_Previous
:
“Pager_Next”和“Pager_Previous”的Liquid替换或模板示例:
{% shape_clear_alternates Model %}
<font color=#0099ff size=4 face="黑体">{%shape_clear_alternates型号%}</font>
{% shape_type Model "Pager_Link" %}
<font color=#0099ff size=4 face="黑体">{%shape_type型号“Pager_Link”%}</font>
{% shape_add_classes Model "page-link" %}
<font color=#0099ff size=4 face="黑体">{%shape_add_classes模型“页面链接”%}</font>
{{ Model | shape_render }}
<font color=#0099ff size=4 face="黑体">{{型号| shape_render}}</font>
Each of these shapes are ultimately morphed into Pager_Link
这些形状中的每一个最终都变成了“Pager_Link”
Alternates for each of these shapes are created using the PagerId like Pager_Previous__[PagerId]
which
每个形状的替代都是使用_PagerId_创建的,如Pager_Previous __ [PagerId]
would in turn look for the template Pager-MainBlog.Previous.cshtml
.
反过来会寻找模板Pager-MainBlog.Previous.cshtml
。
Extending Navigation
扩展导航
Navigation can be extended, through code, by implementing INavigationProvider
and registering it in the extending module (or theme) Startup.cs
file.
可以通过代码扩展导航,实现INavigationProvider
并将其注册到扩展模块(或主题)Startup.cs
文件中。
Below is a sample implementation of an INavigationProvider
used to extend the "main" navigation section of the site.
下面是用于扩展站点“主”导航部分的INavigationProvider
的示例实现。
public class MainMenu : INavigationProvider
<font color=#0099ff size=4 face="黑体">公共类MainMenu:INavigationProvider</font>
{
public MainMenu(IStringLocalizer<MainMenu> localizer)
{
T = localizer;
}
<font color=#0099ff size=4 face="黑体"></font>
public IStringLocalizer T { get; set; }
<font color=#0099ff size=4 face="黑体"></font>
public async Task BuildNavigation(string name, NavigationBuilder builder)
{
//Only interact with the "main" navigation menu here.
if (!String.Equals(name, "main", StringComparison.OrdinalIgnoreCase))
{
return;
}
<font color=#0099ff size=4 face="黑体"></font>
builder
.Add(T["Notifications"], T["Notifications"], layers => layers
.Action("Index", "Template", new { area = "CRT.Client.OrchardModules.CommunicationTemplates", groupId = 1 })
.LocalNav()
);
}
}
This provider will be called as long as the site is using a theme that includes a line similar to the following, which causes the navigation menu to be rendered by your theme at the location specified:
只要站点使用包含类似于以下内容的主题的主题,就会调用此提供程序,这会导致导航菜单由主题在指定的位置呈现:
@await DisplayAsync(await New.Navigation(MenuName: "main", RouteData: @ViewContext.RouteData))
Examples of extending the admin navigation can be found in various OrchardCore modules. Searching the repository for "AdminMenu" will locate various settings. Below is a partial list:
扩展管理导航的示例可以在各种OrchardCore模块中找到。在存储库中搜索“AdminMenu”将找到各种设置。以下是部分清单:
OrchardCore.Modules/OrchardCore.Admin/AdminFilter.cs
OrchardCore.Modules/OrchardCore.Media/AdminMenu.cs
At this time, the Admin Menu is the only navigation with code dynamically adding items in the OrchardCore git repository. However, as the example above shows, the pattern can be used to control any named navigation.
此时,Admin Menu是唯一一个在OrchardCore git存储库中动态添加项目的代码导航。但是,如上面的示例所示,该模式可用于控制任何命名的导航。