Copied to clipboard

Flag this post as spam?

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


  • David W. 159 posts 284 karma points c-trib
    Jan 15, 2012 @ 21:14
    David W.
    0

    Iterating media items by type

    How can I iterate through children of a Media node, but only of certain types (ie, images). This line of code catches all item types.

    @foreach(var item in Model.MediaById(myId).Children){...}

     Preferably I would like a method so I can define more than one media type (images and files for instance)

  • Tom Fulton 2030 posts 4996 karma points c-trib
    Jan 16, 2012 @ 22:59
    Tom Fulton
    0

    Hi,

    You should be able to do something like this:

      @foreach(var item in Model.MediaById(1050).Children.Where("NodeTypeAlias == \"Image\" || NodeTypeAlias == \"File\""))

    HTH,
    Tom

  • David W. 159 posts 284 karma points c-trib
    Jan 17, 2012 @ 21:15
    David W.
    0

    Alright. I will give that a shoot.

    Thanks.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies