This article goes over how to use the various forum api methods to pull data out of the cms instead of using the forum server control
Create a board/forum/topic
bool auth = true; //require authorization string[] categories = { "test", "test1" }; long parentfolderid = 0; Ektron.Cms.API.Content.ThreadedDiscussion td = new Ektron.Cms.API.Content.ThreadedDiscussion(); long boardid = td.AddBoard(parentfolderid, "Name of the Forum", "Title of the forum", auth, "stylesheet.css", categories); bool modposts = true; //requires moderation of posts bool lockforum = false; //lock users out of posting to forum int sortorder = 1; //order which the forum displays in the list long categoryid = 9; //id of the category the forum belongs to long forumid = td.AddForum(boardid, "Forum Name", "description", modposts, lockforum, sortorder, categoryid); long topicid = td.AddTopic(forumid, "Title of the topic", "message");
Delete a board/forum/topic
Ektron.Cms.API.Content.ThreadedDiscussion td = new Ektron.Cms.API.Content.ThreadedDiscussion(); td.DeleteBoard(boardid); td.DeleteForum(forumid); td.DeleteTopic(topicid);
Add reply to a post
Ektron.Cms.API.Content.ThreadedDiscussion td = new Ektron.Cms.API.Content.ThreadedDiscussion(); Ektron.Cms.FileAttachment[] FileAttachments = new Ektron.Cms.FileAttachment[0]; //list of file attachments associated with the post long userid = 1; //id of the logged in user long postid = 88; //the post being replied to bool approved = true; //approve and publish or wait for approval before reply is published bool anonymous = false; //if true, only displays anonymous, otherwise displays user info td.AddReply(topicid, "reply message", userid, postid, approved, anonymous, "ip address of poster", FileAttachments);
Other Operations
Ektron.Cms.API.Content.ThreadedDiscussion td = new Ektron.Cms.API.Content.ThreadedDiscussion(); int maxnumber = 5; //max number of active topics to retrieve //Get topic info td.GetActiveTopics(boardid, maxnumber); td.GetActiveTopicsForForum(forumid, maxnumber); //get board categories Ektron.Cms.DiscussionCategory[] dc = td.GetBoardCategories(boardid); //get list of discusssion forums by board Ektron.Cms.DiscussionForum[] df = td.GetBoardForums(boardid); //gets the discussion board Ektron.Cms.DiscussionBoard db = td.GetDiscussionBoard(boardid); //gets the forum by id db = td.GetForum(forumid); //gets topic info db = td.GetTopic(topicid); //search for topic replies long[] forumids = { 1, 2 }; string[] searchterms = { "test", "test1" }; Ektron.Cms.Content.EkTasks ekt = td.SearchReplies(forumids, searchterms, Ektron.Cms.Common.EkEnumeration.SearchTypes.ContainsWords); //subscribe to board, forum, and topic td.SubscribeToBoard(boardid, userid, Ektron.Cms.Common.EkEnumeration.NotificationType.All); //watch type td.SubscribeToForum(forumid, userid, Ektron.Cms.Common.EkEnumeration.NotificationType.Replies); td.SubscribeToTopic(topicid, userid, Ektron.Cms.Common.EkEnumeration.NotificationType.Never); //unsubscribe td.UnSubscribeToBoard(boardid, userid); td.UnSubscribeToForum(forumid, userid); td.UnSubscribeToTopic(topicid, userid);
Please sign in to leave a comment.