Skip to content

Autoroute (OrchardCore.Autoroute)

Autoroute(OrchardCore.Autoroute)

This module allows you to specify custom URLs (permalink) for your content items.

此模块允许您为内容项指定自定义URL(永久链接)。

Autoroute Part

自动部件

Attach this part to a content type to specify custom URLs to your content items.

将此部分附加到内容类型以指定内容项的自定义URL。

Then, go to the definition of a Content Type and edit the Autoroute Part:

然后,转到内容类型的定义并编辑自动部件:

  • Enter a Pattern using a Liquid expression that will represent the generated slug.

  • 使用Liquid表达式输入Pattern,该表达式将表示生成的slug。

Example for a content with a TitlePart that will use it to generate the slug :

具有TitlePart的内容的示例将使用它来生成slug:


{{ ContentItem | display_text | slugify }}

 <font color=#0099ff size=4 face="黑体">{{ContentItem | display_text | slugify}}</font> 


Example for a content with a ListPart and a TitlePart (ig: BlogPost nested in a Blog) that will use the container and the title to generate the slug:

具有ListPart和TitlePart(ig:BlogPost嵌套在博客中)的内容示例将使用容器和标题生成slug:


{{ ContentItem | container | display_text | slugify }}/{{ ContentItem | display_text | slugify }}`

 <font color=#0099ff size=4 face="黑体">{{ContentItem |容器| display_text | slugify}} / {{ContentItem | display_text | slugify}}`</font> 


  • If you want to be able to enter a custom path when you edit a content item, check 'Allow custom path'.

  • 如果您希望在编辑内容项时能够输入自定义路径,请选中“允许自定义路径”。

  • If you want to be able to set a content item as the homepage, check 'Show homepage options'

  • 如果您希望能够将内容项目设置为主页,请选中“显示主页选项”

Autoroute Alias

Autoroute Alias

Content items with an Autoroute can be retrieved by URL anywhere you can retrieve content by alias (see example below). The syntax for this is slug:<URL>, e.g. slug:my-blog/my-blog-post.

只要您可以通过别名检索内容,就可以通过URL检索具有Autoroute的内容项(请参阅下面的示例)。这个的语法是slug:<URL>,例如毛坯:我-博客/我 - 博客 - POST

Liquid

液体

With Autoroute enabled, you can retrieve content by URL in your liquid views and templates:

启用Autoroute后,您可以在液体视图和模板中按URL检索内容:


{% assign my_content = Content["slug:my-blog/my-blog-post"] %}

 <font color=#0099ff size=4 face="黑体">{%assign my_content = Content [“slug:my-blog / my-blog-post”]%}</font> 


or

要么


{% assign my_content = Content.Slug["my-blog/my-blog-post"] %}

 <font color=#0099ff size=4 face="黑体">{%assign my_content = Content.Slug [“my-blog / my-blog-post”]%}</font>