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 

     
  • 相关阅读:
    我的第一篇博客/markdown
    iOS开发编码建议与编程经验
    iOS 知识点梳理
    Objective-C中类和对象的介绍
    Linux虚拟机部署单机solr报错500解决方法之一
    day02:三元运算、布林非、列表等(20170214)
    day01:判断与循环(20170213)
    前端面试题大全2
    前端面试题大全
    [js] charAt()、charCodeAt()、fromCharCode()
  • 原文地址:https://www.cnblogs.com/Qbit/p/9746482.html
Copyright © 2011-2022 走看看