• 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 

     
  • 相关阅读:
    System.Data.SQLite数据库介绍
    php 链接mssql问题 ntext不能读取
    使用NeatUpload上传文件
    js 和后台交互
    oracle学习第五天【RMAN】
    oracle学习第三天【sqlplus常用命令】
    js操作url(window.location)
    jquery资料收集【转】
    php学习3字符串
    linux read命令 小记
  • 原文地址:https://www.cnblogs.com/Qbit/p/9746482.html
Copyright © 2020-2023  润新知