Get all type of umbraco document with razor

I have the document type "info". I also have certain custom properties.

infoTitle infoSummary infoBody

I want to get all the documents, such as an information document, and display the data.

thank

+5
source share
1 answer

This simple razor macro should do what you want:

@{
    // 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>
}
+13
source

All Articles