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. [源代码]List的增加与删除

    // Removes the element at the given index. The size of the list is // decreased by one. // public vo ...

  2. PIE SDK矢量数据编辑的撤销和回退

    1.功能简介 在数据的编辑过程中难免会出现失误,撤销和回退可以更好的编辑,下面对矢量数据编辑的撤销和回退功能进行介绍. 2.功能实现说明 2.1. 实现思路及原理说明 第一步 调用UndoComman ...

  3. PIE SDK缨帽变换

    1.算法功能简介 缨帽变换是根据多光谱遥感中土壤.植被等信息在多维光谱空间中信息分布结构对图像做的经验性线性正交变换. PIE 支持对 Landsat MSS. Landsat 5 TM.Landsa ...

  4. 在ASP.NET Core Web API 项目里无法访问(wwwroot)下的文件

    解决办法:在“ Startup.cs ” 文件里的 Configur方法里添加一句代码“ app.UseStaticFiles() ”,这样就可以访问wwwroot下的文件了. - 方法代码是: - ...

  5. Android应用捕获全局异常自定义处理

    [2016-06-30]最新的全局异常处理DRCrashHandler已经集成在DR_support_lib库中 具体请看: https://coding.net/u/wrcold520/p/DR_s ...

  6. vue工程中使用iconfont在线CDN不生效的问题

    为什么在vue工程中引入iconfont有时候不生效呢? 请依次使用以下方法 1. 在index.html中引入在线资源 <!DOCTYPE html> <html lang=&qu ...

  7. PHP冒泡排序的实现方法

    <?php function BubbleSort($arr){ $count = count($arr); if($count<=1){ return $arr; } for($i=0; ...

  8. Thinking in java源码下载链接

    Thinking in java书上显示的下载源码到www.mindview.net站点,但是这个站点打不开了,后来找到真正的下载地址,贴于此. http://www.mindviewinc.com/ ...

  9. python 生成、删除、拷贝目录

    1. 生成目录 函数原型:distutils.dir_util.mkpath(name[, mode=0777, verbose=0, dry_run=0]) from distutils impor ...

  10. 【shell】《shell学习指南》读书笔记

    一.使用shell脚本 优点:脚本语言能够轻易处理文件与目录之间的对象,如把文件从所有目录拷贝到另一个目录 缺点:效率不如编译型语言 二.简单的脚本 1.查看现在系统有谁登录 $who 2.算出行数 ...