The following sample code shows how you can create a new forum group and forum and add them to the system:
[C#]
using CMS.Forums; using CMS.CMSHelper; using CMS.SiteProvider;
...
// Create new forum group info ForumGroupInfo fgi = new ForumGroupInfo();
// Set properties fgi.GroupName = "CustomForumGroup"; fgi.GroupDisplayName = "Custom forum group"; fgi.GroupSiteID = CMSContext.CurrentSiteID; fgi.GroupAuthorDelete = true; fgi.GroupAuthorEdit = true; fgi.GroupDisplayEmails = true;
// Save object to database ForumGroupInfoProvider.SetForumGroupInfo(fgi);
// Get Forum group object fgi = ForumGroupInfoProvider.GetForumGroupInfo("CustomForumGroup", CMSContext.CurrentSiteID);
// If forum group exists if (fgi != null) { // Create new forum object ForumInfo fi = new ForumInfo();
// Set properties fi.ForumName = "CustomForum"; fi.ForumDisplayName = "Custom forum"; fi.AllowAccess = SecurityAccessEnum.AllUsers; fi.AllowAttachFiles = SecurityAccessEnum.AuthenticatedUsers; fi.AllowPost = SecurityAccessEnum.AllUsers; fi.AllowReply = SecurityAccessEnum.AllUsers; fi.AllowSubscribe = SecurityAccessEnum.AllUsers; fi.ForumGroupID = fgi.GroupID; fi.ForumOpen = true; fi.ForumModerated = false; fi.ForumThreads = 0; fi.ForumPosts = 0; fi.ForumSiteID = fgi.GroupSiteID;
// Save new forum to database ForumInfoProvider.SetForumInfo(fi);
} |
Page url: http://devnet.kentico.com/docs/devguide/index.html?creating_forums.htm