Original: https://www.cnblogs.com/Qbit/p/9746482.html
CMS modules»contents
Contents (orchardcore.contents)
This module provides content management services.
Liquid
You can access content items from liquid view and templates using the "Content" property. By default, you can retrieve content by alias or content item ID. Other modules, such as Alias and Autoroute, allow you to retrieve content from other identifiers.
You can access content items from liquid views and templates by using the property Content . By default, you can retrieve content by alias or content item ID. Other modules (such as Alias and Autoroute) allow you to retrieve content by other identifiers.
Loading from aliases
{% Assign my_content = content["Alias:main-menu"]%}
Aliases can be in various forms, such as using the slug prefix when using autoroute.
{% Assign my_content = content["Slug:my-blog/my-blog-post"]%}
Aliases are implemented by providing icontentaliasprovider.
Load the latest version of a content item
You can use the latest property to retrieve the latest version of a content item (whether it's a published version or the latest draft version) by using an alias
{% Assign my_content = content.latest["Alias:main-menu"]%}
Loading from the Content item ID
{% Assign my_content = content.contentitemid["417qsjrgv97e74wvp149h4da53"]%}
Loading from the content Item version ID
{% Assign my_content = content.contentitemversionid["49gq8g6zndfc736x0az3zsp4w3"]%}
Razor Helper
The razor helper in the Orchardcore.contentmanagement namespace provides the following methods
| Method |
Parameters |
Description |
GetContentItemIdByAliasAsync |
string alias |
Returns the content item ID from the alias. |
GetContentItemByAliasAsync |
string alias, bool latest = false |
Loads the content item from its alias, seeking the latest version. |
GetContentItemByIdAsync |
string contentItemId, bool latest = false |
Loads the content item from its ID, seeking the latest version. |
GetContentItemByVersionIdAsync |
string contentItemVersionId |
Loads a content item from its version ID. |
Orchard Core Document Translation (vii) Contents