Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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.
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>} }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
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.
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>
}
}
is working on a reply...