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帮助程序提供了以下方法

Method Parameters Description
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

 

Orchard Core 文档翻译 (七)Contents的更多相关文章

  1. Orchard Core 文档翻译 (二)代码生成模板 Code Generation Templates

    Code Generation Templates 翻译原文:https://www.cnblogs.com/Qbit/p/9746457.html转载请注明出处 Orchard Core Templ ...

  2. Orchard Core 文档翻译 (三) Orchard Core Modules

    原文连接:https://www.cnblogs.com/Qbit/p/9746442.html 转载请注明出处 介绍 Orchard Core Modules库提供了一种机制,可以拥有一个独立的模块 ...

  3. Orchard官方文档翻译(七) 导航与菜单

    原文地址:http://docs.orchardproject.net/Documentation/Navigation-and-menus 想要查看文档目录请用力点击这里 最近想要学习了解orcha ...

  4. Orchard Core 文档翻译 (六)HTML

    Body (OrchardCore.Html) Theming Shapes 将HtmlBodyPart附加到内容类型时,将呈现以下形状(Shapes) Name Display Type Defau ...

  5. Orchard Core 文档翻译 (五)自动路由 Autoroute (OrchardCore.Autoroute)

    Autoroute (OrchardCore.Autoroute) 此模块允许您为内容项指定自定义URL(永久链接 permalink). Autoroute Part 将此部分附加到内容类型以指定内 ...

  6. Orchard Core 文档翻译 (四)CMS ModulesTitle (OrchardCore.Title)

    Title (OrchardCore.Title) 标题模块提供Title Part ,允许用户定义内容项的标题.它还定义了ContentItemMetadata方面的DisplayText属性 Th ...

  7. Orchard core 中文文档翻译系列

    本系列翻译顺序完全参照 官方顺序 原文地址:https://orchardcore.readthedocs.io/en/latest/ Orchard Core 中文文档翻译(一)关于Orchard ...

  8. Orchard Core 中文文档翻译(一)关于Orchard Core

    原文连接:https://www.cnblogs.com/Qbit/p/9746363.html 转载请注明出处 翻译说明:本系列为直译,按照官方的计划现在这个版本(2018年10月5日)已经接近最终 ...

  9. Orchard Core 自定义权限配置

    在我们为Orchard Core配置了一个新的Module之后,我们要考虑的是谁可以访问这个Module,那么这里就涉及到了一个权限的配置.如下图,添加了自定义的权限: Orchard Core源码: ...

随机推荐

  1. [转] 理解 JavaScript 的 async/await

    [From] https://segmentfault.com/a/1190000007535316      边城 2016年11月19日发布 随着 Node 7 的发布,越来越多的人开始研究据说是 ...

  2. Oracle之UTL_FILE 包用法详解

    [转自] http://zhangzhongjie.iteye.com/blog/1903024 UTL_FILE包可以用来读写操作系统上的文本文件,UTL_FILE提供了在客户端(FORM等等)和服 ...

  3. 合唱团---DP

    https://www.nowcoder.com/practice/661c49118ca241909add3a11c96408c8?tpId=85&tqId=29830&tPage= ...

  4. poj1318 Word Amalgamation 字符串排序(qsort)

    Word Amalgamation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9794   Accepted: 4701 ...

  5. 腾讯云(Linux)安装.net core sdk2.1、net core runtime2.1

    按照微软指令安装: sdk2.1:https://www.microsoft.com/net/download/linux-package-manager/centos/sdk-current 1. ...

  6. pyquery的简单操作

    一.初始化 1.html初始化 html = ''' <div> <ul> <li class="item-0">first item</ ...

  7. Tesorflow-自动编码器(AutoEncoder)

    直接附上代码: import numpy as np import sklearn.preprocessing as prep import tensorflow as tf from tensorf ...

  8. lnmp 优化

    一,版本信息优化 重启 直接更改版本号: 在源码包里改 第二个要改的地方 第三个需要更改的 改完后编译安装,下次我直接写进编译脚本上

  9. select简单示例,有注释

    全部都在代码中: import select import socket import queue """ 简单的select 实现echo server 个人理解: s ...

  10. TOJ 3488 Game Dice

    描述 In the game of Dungeons & Dragons, players often roll multi-sided dice to generate random num ...