Copied to clipboard

Flag this post as spam?

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


  • Balram Narad 37 posts 89 karma points
    Jun 16, 2015 @ 11:08
    Balram Narad
    0

    Displaying Media Items in a explorer like structure

    Hi

    I am trying to display all the files and folders within the media section in a tree like structure eg folder then sub folders then files.

    at the moment all I am getting is a flat file structure showing all the folders at the same level

    My code is below any help much appreciated

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    

    @using umbraco.MacroEngines;

          @{
              var fileId = Model.MacroParameters["DocumentsFolder"];
      
      
      
              if (fileId != null)
              {
      
      
                  var fileList = Umbraco.Media(@fileId).Descendants(1);
      
                  foreach (var file in fileList)
                  {
      
                      if (file.DocumentTypeAlias == "Folder")
                      {
              <li>
                  <h3><i class="fa fa-folder "></i>   @file.Name</h3>
                  <ul>
                      @if (file.Children().Any())
                      {
      
                          foreach (var file2 in file.Children("File"))
                          {
      
                              if (@file2.displaytitle != "")
                              {
      
                          <li><a href="@file2.Url"><i class="fa fa-file "></i>   @file2.displaytitle</a></li>
                              }
                              else
                              {
                          <li><a href="@file2.Url"><i class="fa fa-file "></i>   @file2.Name</a></li>  
                              }
      
                          }
      
      
                      }
                  </ul>
              </li>      
      
                      }
                  }
      
      
      
              }
      
      
      
          }
      
      </ul>
      

    e

Please Sign in or register to post replies

Write your reply to:

Draft