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. HDU 2879 数论

    HeHe Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submis ...

  2. EntityFramework CodeFirst 数据库迁移

    参考: https://msdn.microsoft.com/en-us/data/jj591621 https://msdn.microsoft.com/en-us/library/dd394698 ...

  3. PIE SDK缨帽变换

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

  4. css盒子居中

    方法1(margin: 0 auto)<!DOCTYPE html> <html lang="en"> <head> <meta char ...

  5. oracle 备份恢复篇(三)---rman spfile的丢失

    一,环境准备 1, 拥有全备 数据 2, 查看spfile文件位置 SQL> SQL> SELECT NAME, VALUE, DISPLAY_VALUE FROM V$PARAMETER ...

  6. 对象池3(方法功能)PoolManager(控制)PoolTimeObject(时间管理)text01(调用)Destorys(销毁)

    1.对象池PoolManager namespace kernal { public class PoolManager : MonoBehaviour { //“缓冲池”集合 public stat ...

  7. 阿里云centos 7 中tomcat 自启动

    这里我的tomcat的安装路径为 /usr/local/tomcat 1 为tomcat添加自启动参数 catalina.sh在执行的时候会调用同级路径下的setenv.sh来设置额外的环境变量,因此 ...

  8. 解决 command not found: express

    需要先执行 sudo npm install -g express-generator 再安装 sudo npm install -g express 建立项目骨架 express -e   xxx

  9. TOJ 2861 Octal Fractions

    描述 Fractions in octal (base 8) notation can be expressed exactly in decimal notation. For example, 0 ...

  10. JDBC的PreparedStatement启动事务使用批处理executeBatch()

    JDBC使用MySQL处理大数据的时候,自然而然的想到要使用批处理, 普通的执行过程是:每处理一条数据,就访问一次数据库: 而批处理是:累积到一定数量,再一次性提交到数据库,减少了与数据库的交互次数, ...