1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Order by Custom Image Field

Order by Custom Image Field

2 posts, 0 answered
  1. Coty
    Coty avatar
    29 posts
    Registered:
    25 Aug 2006
    05 Feb 2013
    Link to this post

    I created a custom integer field for images called "Order".   I found I can get this data by doing this: 

    string order = Telerik.Sitefinity.Model.DataExtensions.GetValue(myImage, "Order").ToString();

    So I could do custom ordering, However what I would like to do is take my list of Images and use the OrderBy clause.

    var images = App.WorkWith().Images().Where(im => im.Parent.Title == "rotator" && im.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).Get();
     
            foreach (Telerik.Sitefinity.Libraries.Model.Image v in images.OrderBy(im => im.Title))
            {
                sb.Append("<li><img class='sliderImage' src='" + v.MediaUrl + "'></img></li>");
            }

    The example above shows how I can order by the strongly typed properties and that works fine.  I tried to combine the above two code snippets to figure out how I can order by my custom field but I haven't had any luck.  Is this possible?  And if you can can someone post a code snippet of how to do it?

    Thanks!

    Coty

  2. Coty
    Coty avatar
    29 posts
    Registered:
    25 Aug 2006
    06 Feb 2013 in reply to Coty
    Link to this post
    Bump.

    Is it possible to get an answer on this today?  If it is not possible to order by a custom field than I can write my own but I would like to know before I start, thanks!
2 posts, 0 answered