Umbraco - Racor - C# - Colllections - Add Node ids

If you are working with folders in razor, it may be best to add them as a collection to iterate through instead of having to look work with the folder structure continually:



//Lets Build a collection of the all the documents to look at:

var docuList = new List<string>();

dynamic documentFolders = Library.NodeById(rootMediaFolder);
    foreach (var folders in documentFolders.Children)
{
  dynamic subFolders = Library.NodeById(@folders.Id);
  foreach (var thisDocuments in subFolders.Children)
{
docuList.Add(@thisDocuments.id);
}
}


foreach (var document in docuList)
{
@document
}

Comments

Popular posts from this blog

Umbraco Razor Sort Nodes Ascending or Descending

Umbraco Razor get Querystring

Create a .NET Contact Form that Gets the Last Url Visited in C# Can also be Used in Umbraco