Copied to clipboard

Flag this post as spam?

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


  • Graham Carr 277 posts 389 karma points
    Oct 02, 2012 @ 12:28
    Graham Carr
    0

    Embedded Content Display Order

    I have an embedded content data type on one of my pages, and this has a display order field. I am using RAZOR to retrieve the embedded content items which all works fine, but I can't work out how to order the items by the display order field that I created.

    My loop is as follows:

    @foreach (var item in Model.colourCharts.item)
    {
      dynamic mediaItem = new DynamicMedia(item.icon.InnerText);

      dynamic downloadItem = new DynamicNode(item.download.InnerText);
    }

    And the display order field is called displayOrder. I am guessing I need to use the OrderBy LINQ function but have tried different ways and can't get it to work.


    Any ideas/solutions would be more than welcome.

  • Kasper Dyrvig 246 posts 379 karma points
    Oct 15, 2012 @ 12:08
    Kasper Dyrvig
    0

    Hi Graham,

    In Razor you add the order functionality in the foreach statement. Like this:

    @foreach (var item in Model.colourCharts.item.OrderBy("displatOrder"))
    {
      dynamic mediaItem = new DynamicMedia(item.icon.InnerText);
      dynamic downloadItem = new DynamicNode(item.download.InnerText);
    }

    I hope it works

Please Sign in or register to post replies

Write your reply to:

Draft