I found this code on the Ektron Developer Center (see link below) that pertained mainly to menus but assisted me in getting a folder drill-down so I could add it into my DMS content widget.
Similar to the DMS content widget make sure you setup the proper permissions to the page that lists these as this uses Admin functionality and will show all folders.
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Ektron.Cms; using Ektron.Cms.Framework; using Ektron.Cms.Common; using Ektron.Cms.Framework.Content; using Ektron.Cms.Framework.Organization; using Ektron.Cms.Organization; public partial class special_FolderList : System.Web.UI.Page { private Ektron.Cms.Framework.Organization.FolderManager EkFolderManager = new Ektron.Cms.Framework.Organization.FolderManager(ApiAccessMode.Admin); protected void Page_Load(object sender, EventArgs e) { Response.Write(GetFolder(0)); } private string GetFolder(long folderId) { string Message = String.Empty; try { //Get a list of child folders List<long> FolderIdList = GetChildFolderIDs(folderId, true); //Get a list of folder objects Ektron.Cms.FolderCriteria fcriteria = new FolderCriteria(); fcriteria.AddFilter(FolderProperty.Id, CriteriaFilterOperator.In, FolderIdList); fcriteria.PagingInfo = new PagingInfo(200, 1); //fcriteria.OrderByField = FolderProperty.FolderPath; fcriteria.OrderByField = FolderProperty.Id; fcriteria.OrderByDirection = EkEnumeration.OrderByDirection.Ascending; List<FolderData> folderList = EkFolderManager.GetList(fcriteria); //Loop over the folder list, and generate the menus. Build dictionary list of folder to menu ids foreach (FolderData folder in folderList) { // Message += folder.ParentId.ToString() + "<br/>"; // Message += folder.FolderIdWithPath + "<br/>"; Message += folder.NameWithPath + "<br/>"; } } catch (Exception ex) { Message = ex.Message; } return Message; } public static List<long> GetChildFolderIDs(long FolderID, bool Recursive) { Ektron.Cms.Framework.Organization.FolderManager EkFolderManager = new Ektron.Cms.Framework.Organization.FolderManager(ApiAccessMode.Admin); List<long> folderIDs = new List<long>(); Ektron.Cms.FolderCriteria criteria = new FolderCriteria(); criteria.AddFilter(Ektron.Cms.Common.FolderProperty.ParentId, Ektron.Cms.Common.CriteriaFilterOperator.EqualTo, FolderID); criteria.PagingInfo.RecordsPerPage = 500; List<Ektron.Cms.FolderData> childFolders = EkFolderManager.GetList(criteria); if (childFolders != null) { foreach (var childFolder in childFolders) { if (childFolder.Id > 0) { if (!folderIDs.Contains(childFolder.Id)) { folderIDs.Add(childFolder.Id); } if (Recursive && childFolder.HasChildren) { folderIDs = folderIDs.Union(GetChildFolderIDs(childFolder.Id, Recursive)).ToList(); } } } } return (from ids in folderIDs orderby ids select ids).ToList(); } }
Reference: Ektron Developer Center
Last Updated on October 26, 2015