Get specific page and loop throug the childnodes

In XSLT you can select a specific page by the function GetXmlNodeById and passing the id of the page. In the Razor syntax you select a dynamic node and pass the id, like this:

@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContext
              
@{
    Listpages = new DynamicNode(1962);
}

    <div id="top5"> 
    <h2>Top 5 Articles</h2> 
       @foreach (DynamicNode item in pages) 
       { 
            <div>@item.CreateDate.DayOfWeek</div> 
       }

To select the subpages of this page there is a familiar function: descendingofself, which accepts a document-type parameter, like this

@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContext
              
@{
    Listpages = new DynamicNode(1962).DescendantsOrSelf("Aantekening");
}

    <div id="top5"> 
    <h2>Top 5 Articles</h2> 
       @foreach (DynamicNode item in pages) 
       { 
            <div>@item.CreateDate.DayOfWeek</div> 
       }

Now you easily sort the childnodes on createdate which gets you the list of items in sorted on created date. It's nice that we can use the lambda functions here on the items ( because items is a generic list ).

@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContext
              
@{
    Listpages = new DynamicNode(1962).DescendantsOrSelf("Aantekening").Items.OrderByDescending(a => a.CreateDate).ToList();
}

    <div id="top5"> 
    <h2>Top 5 Articles</h2> 
       @foreach (DynamicNode item in pages) 
       { 
            <div>@item.CreateDate.DayOfWeek</div> 
       }

If we have this list, now we can take the top 5 of that list which gets u the 5 most recent added articles:

@using umbraco.MacroEngines
@inherits umbraco.MacroEngines.DynamicNodeContext
              
@{
    Listpages = new DynamicNode(1962).DescendantsOrSelf("Aantekening").Items.OrderByDescending(a => a.CreateDate).ToList().Take(5).ToList();
}

    <div id="top5"> 
    <h2>Top 5 Articles</h2> 
       @foreach (DynamicNode item in pages) 
       { 
            <div>@item.CreateDate.DayOfWeek</div> 
       }

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!