Copied to clipboard

Flag this post as spam?

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


  • Stefan Arngrimsson 36 posts 59 karma points
    May 26, 2011 @ 13:35
    Stefan Arngrimsson
    0

    How to get top3 last modified nodes

    Hi,

    I'm wondering how I can get the the last three modified nodes from my site. I want to go through the whole site tree and display the newest content in a list.

     

    Any ideas?

    Stefan

  • Sherry Ann Hernandez 320 posts 344 karma points
    May 26, 2011 @ 15:32
  • Richard Boelen 61 posts 153 karma points
    May 27, 2011 @ 20:37
    Richard Boelen
    0

    If you want Razor (why would you not ;-) you could try this:

    @{
        umbraco.MacroEngines.DynamicNodeList list = Model.AncestorOrSelf().DescendantsOrSelf();
        var newest = list.Items.OrderByDescending(x => x.UpdateDate).Take(3);
        foreach(dynamic item in newest){
            <ul>
                <li>@item.Name li>
            <ul>
        }
    }

     

    In this case you lose the 'dynamic' of the DynamicNode though, because of the cast to DynamicNodeList.

    There is some bug in the DynamicNode OrderBy which makes it impossible to use:

    var newest = @Model.AncestorOrSelf().DescendantsOrSelf().OrderBy("updateDate desc").Take(3);

    This gives you just the first 3 items , not ordered by updateDate at all.

    Cheers!

    Richard

  • Stefan Arngrimsson 36 posts 59 karma points
    Jun 21, 2011 @ 16:27
    Stefan Arngrimsson
    0

    Thank you very much Richard :)

  • Andres Tenjo 35 posts 55 karma points
    Jan 08, 2012 @ 04:30
    Andres Tenjo
    0

    Hi some Idea How I can do this sort of last modified nodes with a xslt function ??

    Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft