How to select recently active threads from a particular ad hoc forum

   —   
You may have a requirement to insert several forums into your site, for example if each department should have its own.
To accomplish this, you can use the “Forum (Single -forum -General)” web part and its Forum name property set to “ad-hoc forum”.

This way you will have a unique forum for each department.

Now, you may need to display recently active threads within each forum. For this you can use the “Forum - Recently active threads” web part.

The problem is that this web part will select data from all ad-hoc forums, not just those from within the given forum. To fix this you need to configure its Where condition property. Its value could be ForumId=20 for example.

The ForumID value is found in the Forums_Forum table.

If you do not want to configure this property manually for each document, you can take advantage of custom macros and change the value of the Where condition to ForumID={#myCustomMacro#}.

Then, in the code of your custom macro you can add the following code which returns the ForumID:

TreeNode node = DocumentHelper.GetDocument(CMSContext.CurrentSiteName, CMSContext.CurrentAliasPath,"en-US", true, null, "", "", -1, true, "", new TreeProvider(CMSContext.CurrentUser));
if (node != null)
{
ForumInfo forum = ForumInfoProvider.GetForumInfoByDocument(node.DocumentID);
string forumID = ValidationHelper.ToString(forum.ForumID.ToString(),"0");
}


-it-


See also: Web parts
Custom macro
Forums  

Applies to: Kentico CMS 6.x, 7.x
Share this article on   LinkedIn