zoukankan      html  css  js  c++  java
  • Orchard Core 文档翻译 (七)Contents

    CMS Modules »Contents

    Contents (OrchardCore.Contents)

    此模块提供内容管理服务。

    Liquid

    您可以使用“content ”属性从liquid 视图和templates 访问内容项。 默认情况下,您可以按别名或内容项ID检索内容。 其他模块(如Alias和Autoroute)允许您通过其他标识符检索内容。

    You can access content items from liquid views and templates by 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 by other identifiers.

    从别名加载 

    {% assign my_content = Content["alias:main-menu"] %}
    

    别名可以是各种形式,例如使用Autoroute时,使用slug前缀。

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

    通过提供IContentAliasProvider实现别名。

    加载内容项的最新版本

    您可以使用Latest属性通过别名检索内容项的最新版本(无论是发布的版本还是最新的草稿版本)

    {% assign my_content = Content.Latest["alias:main-menu"] %}
    

    从内容项ID加载 

    {% assign my_content = Content.ContentItemId["417qsjrgv97e74wvp149h4da53"] %}
    

    从内容项版本ID加载 

    {% assign my_content = Content.ContentItemVersionId["49gq8g6zndfc736x0az3zsp4w3"] %}
    

    Razor Helper

    OrchardCore.ContentManagement命名空间中的Razor帮助程序提供了以下方法

    MethodParametersDescription
    GetContentItemIdByAliasAsync string alias 从别名返回内容项ID。
    GetContentItemByAliasAsync string alias, bool latest = false
    从其别名加载内容项,寻求最新版本。
    GetContentItemByIdAsync string contentItemId, bool latest = false
    从其ID加载内容项,寻求最新版本。
    GetContentItemByVersionIdAsync string contentItemVersionId 从其版本ID加载内容项.
     

     原文:https://www.cnblogs.com/Qbit/p/9746482.html 

     
  • 相关阅读:
    数据结构与算法——红黑树
    JAVA数据结构——Map之HashMap
    JAVA数据结构——集合之LinkedList
    在Mac OS X下让你的Terminal带上Color
    Git使用指南(一)
    《乔布斯传》摘录
    必应语音API(Bing text to speech API)
    《设计心理学2》 摘录
    《设计心理学1》 摘录
    第10组 Beta冲刺(4/4)
  • 原文地址:https://www.cnblogs.com/Qbit/p/9746482.html
Copyright © 2011-2022 走看看