Copied to clipboard

Flag this post as spam?

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


  • Robert J. Bullock 386 posts 405 karma points
    Apr 14, 2014 @ 20:06
    Robert J. Bullock
    0

    Media: List files and subfolders?

    I'm surprised I can't figure this one out... What Razor syntax do you use to list all of the children Files and Folders given a Media start node Id? My macro just lists Files or Images, Folders don't show up.

  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 14, 2014 @ 20:36
    Fuji Kusaka
    0

    Hi Robert,

    You can try something like this where you list all folders and everything within the folder

     

    @using System;
    @using umbraco.MacroEngines;
    @using umbraco.BusinessLogic
    @using umbraco.cms.businesslogic.media;
    @using System.Xml;
    @using System.Linq
    @inherits umbraco.MacroEngines.DynamicNodeContext

    @{

        var d = new Media(id);

       if (d.ChildCount > 0)

        {   

           IEnumerable<Media> fd = DocumentLib.GetChildMedia().Where(x => x.ContentType.Alias == "Folder");

                          <ul >

             @foreach (var docFolder in fd) {

    <li>@docFolder</li>

    </ul>

Please Sign in or register to post replies

Write your reply to:

Draft