Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom 143 posts 253 karma points
    Mar 18, 2015 @ 14:55
    Tom
    0

    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 />

        }

     

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies