I am trying to get the 5 latest articles from a set og categories.
Currently I am using this code to get the children of a certain page, but this only get the categories and not the articles:
@{
Dynamicweb.Content.PageCollection articlePages = Dynamicweb.Content.Page.GetPagesByParentID(31);
}
<ul>
@foreach(var page in articlePages.Where(x => x.Active).Take(5)){
<li>
<a href="/Default.aspx?ID=@page.ID" title="@page.MenuText">@page.MenuText</a>
</li>
}
</ul>
This is my page structure:
- Article top page
- Article Category 1
- Article
- Article
- Article Category 2
- Article
- Article
- Article Category 3
- Article
- Article
- Article Category 1
How can I get all articles, from all categories, in the same loop and sort them by date?