Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Ektron Framework API – List Folders

Posted on February 3, 2015October 26, 2015 By David Kittell

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

Originally Posted on February 3, 2015
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

C# Ektron Code

Post navigation

Previous post
Next post

Related Posts

MSSQL Table Backup Script

Posted on August 20, 2015October 26, 2015

This is a quick way to backup table structure and data, this will go out to the system table and query all tables then provide a script to recreate the tables. SELECT ‘create table [’ + so.NAME + ‘] (‘ + o.list + ‘)’ + CASE WHEN tc.Constraint_Name IS NULL…

Read More

Delete Logs Older Than 6 Months

Posted on February 25, 2013October 26, 2015

DELETE FROM LogTable WHERE log_datetime < dateAdd(m, -6, getDate()) Originally Posted on February 25, 2013Last Updated on October 26, 2015 All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test…

Read More

Medicare Health Assessment Report

Posted on August 8, 2013October 26, 2015

— Valid NPI or Prov# – Start SELECT (last_name + ‘, ‘ + first_name) AS Provider ,LTRIM(RTRIM(NPI_nbr)) AS NPI# ,LTRIM(RTRIM(amisys_prov_nbr)) AS Provider# ,( SELECT COUNT(*) TotalCount FROM MedicareHealthAssessment WHERE providerid = LTRIM(RTRIM(vp.amisys_prov_nbr)) GROUP BY providerid ) AS TotalCountByProvNum ,( SELECT COUNT(*) TotalCount FROM MedicareHealthAssessment WHERE prov_NPI = LTRIM(RTRIM(vp.NPI_nbr)) GROUP BY…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • Front Page
  • PowerShell - IIS Remove Site
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • PowerShell - IIS Remove Site
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories
  • Raspberry Pi - Remove Default Apps
  • PowerShell - Change Windows CD/DVD Drive Letter
©2025 David Kittell | WordPress Theme by SuperbThemes