x First time here? Check out the FAQ

Come work for Umbraco - The Umbraco HQ are hiring Project managers, .NET developers and DevOps people!

  • Avatar87posts172karma

    Get all media sorted by date

    Matthias started this topic May 16, 2012 @ 10:17

    Hi,

    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);
    <ul>
      @foreach(var doc in docs.DescendantsOrSelf("File").OrderBy("updateDate desc").Take(5)){     <li><a href="@doc.umbracoFile">@doc.Name</a></li>   }
    </ul> }

    Any hints?

    Thanks


  • Avatar291posts323karma
    Comment with ID: 117316
    Grant Thomas posted this reply May 16, 2012 @ 10:26

    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".


  • Avatar87posts172karma
    Comment with ID: 117317
    Matthias posted this reply May 16, 2012 @ 10:30

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


  • Avatar108posts132karma
    Comment with ID: 118572
    Trevor Loader posted this reply June 1, 2012 @ 04:37

    Do you ever get this to work?


  • Avatar2038posts3794karma
    Comment with ID: 118578
    Fuji Kusaka posted this reply June 1, 2012 @ 08:33

    Hi Matthias

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

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

    //fuji


  • Avatar87posts172karma
    Comment with ID: 118582
    Matthias posted this reply June 1, 2012 @ 08:45

    Hi,

    @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.

    Matthias


Please login or Sign up To post replies