Last chance to get discounted tickets to Codegarden... Price goes up on Tuesday at 20:00 CEST!

Copied to clipboard

Flag this post as spam?

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

  • Matthias 87 posts 173 karma points
    May 16, 2012 @ 10:17

    Get all media sorted by date


    can't get this to work. I want to receive the last 5 updated/created media items of type "File" from a complex subfolder structure in the media section.
    It's no problem to order it by "Name" (asc and desc), but ordering by date fails (asc and desc).

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @using umbraco.MacroEngines
      var docs= Model.MediaById(1071);
      @foreach(var doc in docs.DescendantsOrSelf("File").OrderBy("updateDate desc").Take(5)){     <li><a href="@doc.umbracoFile">@doc.Name</a></li>   }
    </ul> }

    Any hints?


  • Grant Thomas 291 posts 323 karma points
    May 16, 2012 @ 10:26
    Grant Thomas

    Did you try and order by "UtcModified"? May or may not work, that's the actual name of the property on the ITypedEntity type (or something) rather than an "alias".

  • Matthias 87 posts 173 karma points
    May 16, 2012 @ 10:30

    thanks, but doesn't work.
    Sorry, forgot to mention an important bit: should work with Umbraco

  • Trevor Loader 197 posts 254 karma points
    Jun 01, 2012 @ 04:37
    Trevor Loader

    Do you ever get this to work?

  • Fuji Kusaka 2196 posts 4189 karma points
    Jun 01, 2012 @ 08:33
    Fuji Kusaka

    Hi Matthias

    Try Changing this OrderBy("updateDate desc") to OrderBy("id desc").

    I had the same issue when trying to order by createDate.


  • Matthias 87 posts 173 karma points
    Jun 01, 2012 @ 08:45


    @Trevor: no, i switched to a usercontrol and solved it via the api.

    @Fuji: thanks, sounds indeed like a good workaround - will give it a try.


Please Sign in or register to post replies

Write your reply to: