Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get all of document type umbraco with razor

I have a document type of "info" I also have some custom properites.

infoTitle infoSummary infoBody

I want to retrieve all the documents of document type "info" and output the data.

Thanks

like image 886
LeBlaireau Avatar asked Jun 18 '12 09:06

LeBlaireau


1 Answers

This simple razor macro should accomplish what you desire:

@{
    // 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>
}
like image 196
Douglas Ludlow Avatar answered Sep 22 '22 18:09

Douglas Ludlow