I have created the following Razor code which works great (see below).
But for our users and site, we see the below code being used in several places.
As such, we have created a custom property on the document type called category. For the content, we have created three top levels (News, Publications and Current Events). All three will use our partial code below to show the various articles.
I would like to know if I can how do I construct the Where clause so that I filter the articles by category.
Thanks
Tom
@foreach (var page in CurrentPage.Children.Where("Visible").OrderBy("CreateDate desc"))
Filter for Articles
I have created the following Razor code which works great (see below).
But for our users and site, we see the below code being used in several places.
As such, we have created a custom property on the document type called category.
For the content, we have created three top levels (News, Publications and Current Events). All three will use our partial code below to show the various articles.
I would like to know if I can how do I construct the Where clause so that I filter the articles by category.
Thanks
Tom
@foreach (var page in CurrentPage.Children.Where("Visible").OrderBy("CreateDate desc"))
{
<div class="article">
<div class="articleTitle"><a href="@page.Url">@page.Name</a></div>
<div class="articlepreview">@Umbraco.Truncate(@page.articleContent,50) <a href="@page.Url">Read More..</a></div>
</div>
<hr />
}
is working on a reply...