Orchard Core Document Translation (vii) Contents

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.