Copied to clipboard

Flag this post as spam?

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


  • Dan 1285 posts 3917 karma points c-trib
    Oct 30, 2012 @ 13:42
    Dan
    0

    Loop through media items in folder with Razor in umbraco 4.9.0

    Hi,

    I'm looking to loop through all media items in a media folder with Razor in Umbraco 4.9.0, but none of the examples I've tried seem to work (possibly because the razor implementation has changed).

    Can anyone point me in the direction of something that works, preferably without depending on uComponents/uQuery?

    Thanks y'all!

  • Dan 1285 posts 3917 karma points c-trib
    Oct 30, 2012 @ 13:50
  • Rahmathullah 7 posts 85 karma points
    Sep 24, 2014 @ 11:21
    Rahmathullah
    0
    <umbraco:Macro  runat="server" language="cshtml">
        @using umbraco.MacroEngines; 
        @using umbraco.cms.businesslogic.media;
        @{ 
            dynamic mediaFolder = new DynamicMedia(1113); 
            foreach(dynamic pdf in mediaFolder.Children){
                <li><a target="_blank" href="@pdf.umbracoFile">@pdf.GetPropertyValue("Name")</a> </li>
            } 
        }
    </umbraco:Macro>
Please Sign in or register to post replies

Write your reply to:

Draft