Sitefinity CMS

Deleting Forum Categories Send comments on this topic.
See Also
Developing with Sitefinity > Modules > Modules API > Forums > Forum Categories > Deleting Forum Categories

Glossary Item Box

There are two methods for deleting a category:

  • DeleteCategory(ICategory category) - Pass the category that will be deleted
  • DeleteCategory(Guid categoryID)  - Pass the ID of the category that will be deleted

Delete a specified category:

DeleteCategory(ICategory category) Copy Code
// create new instance of ForumManager
Telerik.Forums.ForumManager forumManager = new Telerik.Forums.ForumManager();
// get all cetgories
IList listOfAllCategories = forumManager.GetCategories();
if (listOfAllCategories.Count > 0)
{
   
// get first category
   
Telerik.Forums.ICategory firstCategory = forumManager.GetCategory(((Telerik.Forums.ICategory)listOfAllCategories[0]).ID);
 
   
// delete the category
   
forumManager.DeleteCategory(firstCategory);
}

 

Delete a category by specified ID:

DeleteCategory(Guid categoryID) Copy Code
// create new instance of ForumManager
Telerik.Forums.ForumManager forumManager = new Telerik.Forums.ForumManager();
// get all cetgories
IList listOfAllCategories = forumManager.GetCategories();
if (listOfAllCategories.Count > 0)
{
   
// get ID of the first category
   
Telerik.Forums.ICategory firstCategory = forumManager.GetCategory(((Telerik.Forums.ICategory)listOfAllCategories[0]).ID);
   Guid firstCategoryId = firstCategory.ID;
   
// delete the category
   
forumManager.DeleteCategory(firstCategoryId);
}

 

See Also