CS2007: Add BBCode support to Blogs
Back in 2006 I noticed that BBCodes weren't supported in blogs, so I created the post New Functionality: BBCodes in Blogs to correct this very serious oversight. The same issue exists in CS 2007, so its time to rectify this egregious shortcoming. To do this you can either install Community Server Addons v1.1 for .NET 2.0 or make the following changes to the SDK:
Create a new class CommunityServerBlogs20/Components/Modules/WeblogBBCodeModule.cs and replace the contents of the newly created class file with:
using System;
using System.Xml;
using CommunityServer.Components;
namespace CommunityServer.Blogs.Components
{
/// <summary>
/// Summary description for WeblogBBCodeModule.
/// </summary>
public class WeblogBBCodeModule : ICSModule
{
public WeblogBBCodeModule() { }
public void Init(CSApplication csa, XmlNode node)
{
csa.PrePostUpdate += new CSPostEventHandler(csa_PrePostUpdate);
}
private void csa_PrePostUpdate(IContent content, CSPostEventArgs e)
{
if (e.ApplicationType == ApplicationType.Weblog)
{
WeblogPost wp = content as WeblogPost;
if (wp != null && e.State != ObjectState.Delete)
{
wp.FormattedBody = Transforms.BBcodeToHtml(wp.FormattedBody);
}
}
}
}
}
Then within the CommunityServer/CSModules element of the communityserver.config file, find the following block and insert the bolded line:
<add name = "MetaBlogExtender" type = "CommunityServer.Blogs.Components.MetaBlogExtender, CommunityServer.Blogs" />
<add name = "PostandArticleTokens" type = "CommunityServer.Blogs.Components.PostandArticleTokens, CommunityServer.Blogs" />
<add name = "WeblogCensorModule" type = "CommunityServer.Blogs.Components.CensorModule, CommunityServer.Blogs" />
<add name = "WeblogPostandArticleHtmlScrubbing" type = "CommunityServer.Blogs.Components.PostandArticleHtmlScrubbing, CommunityServer.Blogs" />
<add name = "WeblogFeedbackHtmlFormatting" type = "CommunityServer.Blogs.Components.FeedbackHtmlFormatting, CommunityServer.Blogs" />
<add name = "WeblogFormattingModule" type = "CommunityServer.Blogs.Components.WeblogFormattingModule, CommunityServer.Blogs" />
<add name = "WeblogBBCodeModule" type = "CommunityServer.Blogs.Components.WeblogBBCodeModule, CommunityServer.Blogs" />
<add name = "WeblogEmoticonsModule" type = "CommunityServer.Blogs.Components.WeblogEmoticonsModule, CommunityServer.Blogs" />
<add name = "TrackbackModule" type = "CommunityServer.Blogs.Components.TrackbackModule, CommunityServer.Blogs" />
<add name = "XmlRpcPingModule" type = "CommunityServer.Blogs.Components.XmlRpcPingModule, CommunityServer.Blogs" />
<add name = "WeblogEmailNotificationModule" type = "CommunityServer.Blogs.Components.WeblogEmailNotificationModule, CommunityServer.Blogs" />
<add name = "AutoBlogCreate" type = "CommunityServer.Blogs.Components.AutoBlogCreate, CommunityServer.Blogs" />
<add name = "WeblogCrossPostingModule" type = "CommunityServer.Blogs.Components.WeblogCrossPostingModule, CommunityServer.Blogs" />
<add name = "ImageAttachmentModule" type = "CommunityServer.Blogs.Components.ImageAttachmentModule, CommunityServer.Blogs" />
The order of the above lines is very critical, so make sure you insert in correct spot. CONGRATULATIONS!!! You are done.