用剃刀获取所有文档类型umbraco

时间:2012-06-18 09:47:41

标签: list razor document umbraco

我的文档类型为“info”我也有一些自定义属性。

infoTitle infoSummary infoBody

我想检索文档类型“info”的所有文档并输出数据。

谢谢

1 个答案:

答案 0 :(得分:13)

这个简单的剃​​刀宏可以达到你想要的效果:

@{
    // Get root node:
    var root = Model.AncestorOrSelf();

    // Get all descendants, filter by type:
    var nodes = root.Descendants("info");

    // Loop through the filtered nodes, displaying the properties:
    <ul>
    @foreach (var node in nodes)
    {
        <li>
            <h2>@node.infoTitle</h2>
            <div>@node.infoSummary</div>
            <div>@node.infoBody</div>
        </li>
    }
    </ul>
}