protected IEnumerable <String> GetCategories(String parentName) { CategoryInfo info = CategoryInfoProvider.GetCategoryInfo(parentName, CMSContext.CurrentSite.SiteName); var children = CategoryInfoProvider.GetChildCategories(info.CategoryID, null, null, -1, null, CMSContext.CurrentSite.SiteID); children.AsEnumerable().ToArray(); }
/// <summary> /// Populates the List with the children nodes. /// </summary> /// <param name="ParentCategoryNode">The Parent Category, can be null if it's the root</param> /// <param name="ParentNode">The Parent Tree Node</param> /// <param name="SelectedCategories">The currently selected categories</param> private void CreateChildTreeNodes(CategoryInfo ParentCategoryNode, ref TreeNode ParentNode, ref List <CategoryInfo> SelectedCategories) { // Grab all valid child categories var ChildCategories = (ParentCategoryNode == null ? CategoryInfoProvider.GetCategories(AllowableCategoryIDWhere, DefaultSortOrder, -1, null, SiteContext.CurrentSiteID).WhereEquals("CategoryLevel", 0) : CategoryInfoProvider.GetChildCategories(ParentCategoryNode.CategoryID, AllowableCategoryIDWhere, DefaultSortOrder, -1, null, SiteContext.CurrentSiteID)); foreach (CategoryInfo childCategory in ChildCategories) { TreeNode childTreeObj = new TreeNode(GetInputDataPrepend(childCategory), GetNodeValue(childCategory)); childTreeObj.SelectAction = TreeNodeSelectAction.None; // Must save as ID childTreeObj.Expanded = (childCategory.CategoryLevel < ExpandCategoryLevel); SetNodeChecked(childTreeObj, childCategory); // If either all items selectable, or if only leaf selectable and this is a leaf node, save to the possible categories list. if (childCategory.Children.Count == 0 || !OnlyLeafSelectable) { PossibleCategories.Add(childCategory); } CreateChildTreeNodes(childCategory, ref childTreeObj, ref SelectedCategories); ParentNode.ChildNodes.Add(childTreeObj); } }