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 

     
  • 相关阅读:
    php数据库常用函数
    什么是RESTful API
    RESTful API 设计指南
    json和jsonp的使用区别
    Memcached, Redis, MongoDB区别
    入门系列之在Nginx配置Gzip
    100行代码搞定抖音短视频App,终于可以和美女合唱了。
    游戏开发者注意!这个音频SDK可以完美兼容所有主流游戏引擎
    快速上手:在CVM上安装Apache
    聚焦小游戏技术生态,腾讯游戏云GAME-TECH落地厦门
  • 原文地址:https://www.cnblogs.com/Qbit/p/9746482.html
Copyright © 2011-2022 走看看