Community Server on my mind

J-O Eriksson's blog


  • Running on CS 2.1 SP 2

    See top menu for subscription options

    Technology Blogs - Blog Top Sites

    BlogRankers.com

    Add to Technorati Favorites



The Secrets of CSModules

Listen to this article Listen to this article

Whether you are a developer, or a Community Server admin that haven't got much experience of .NET Development, I believe you should benefit from this article. This article gives you an overview of what CSModules are, how can you benefit from them, and also a collection of resources to find out more, and maybe start using CSModules and the benefits of them right away.

Any developer that has been involved the slightest bit in developing upon Community Server has most probably been in contact with the concept CSModules and know what they are. But for many new users of CS, if they are developers or not, they are a bit of a "secret", maybe not so widely communicated as it could be.

There have been other posts in this subject by other bloggers before (some of them listed in the Resources section of this article), with this article I hope to primarily reach those who not yet have had much experience in CS Development and/or non-developers that are running CS Sites.

What is a CSModule?

A simple explanation could be: A software module that adds to, or modifies, Community Servers functionality.

Can it modify any functionality of CS? No, it can't, CSModules is not the answer to any add-on you want to do on CS. But there is a large area where they can be useful.

CSModules are built to hook into certain events in CS, and when that event occurs you can run your code. Events that you can hook into includes:

  • A new post is created
  • A post is updated
  • A new user is created
  • A user is updated
  • An exception occurs

A more complete list of events available can be found later in the Resources section below.

How do I create a CSModule?

Now you may need to be a developer, with preferably knowledge in .NET Framework development. But the basics are pretty easy.

  1. Start your Visual Studio 2003 or 2005 and create a new Class Library project in C# or VB. (You could of course develop a CSModule without Visual Studio, but I am consciously ignoring that in this article)
  2. Add a reference to CommunityServer.Components.DLL. (Depending on what you want to do you might need other references as well, but this is for basic functionality)
  3. Make your Class implement the ICSModule interface.
  4. Add a handler to one of the CS Application events. (A list of available events can be found in the 'Resources' section below)
  5. Create a method that handles the event you hooked into.

After that you should be ready to go. For a link to a more detailed description of this, see the Resources section of this post.

How do I install a CSModule?

Once you created your CSModule, and compiled it to a DLL, the basic steps you need to do is:

  1. Copy the DLL to the BIN folder of your CS installation
  2. Add a line to the communityserver.config so CS loads your module.

Depending on the complexity of the CSModule there might be more things to consider, i.e. input parameters to give the CSModule at load time. But these are the basic steps.

Interactive CSModules or not - Text Parts?

CSModules can do their work without any user interaction. For example, send an e-mail to the administrator when a new user joins your site, or include an Ad in a post if it is viewed via a RSS-feed.

In some cases you might want the user to input some information that you will use in the code and functionality of your CSModule. A good example could be a CSModule that invokes code for viewing a video in a videoplayer into the post. In that case you'd want the user to input i.e. the path to that video.

A common way to take care of user input to CSModules is to use Community Server's Text Part Frame work. A Text Part is normally added to a post by enclosing a Name and Value pair within square brackets. For example:

[InsertMyVideo: http://mydomain.com/myvideo/filenameofvideo.ext]

When the post is viewed, this is replaced by something else. In the above example it could be some HTML code to show a videoplayer and load the desired video.

Text Parts can be used in many ways. One of them is to add interactivity to your CSModule. In your code you can check if the post contains Text Parts of a given name, read in the parameter(s), and replace them with something that your CSModule code generates.

Resources

In this section I will list a few useful resources that I have found regarding CSModules. It is not a complete list, but it list the ones I have found, and some of them have helped me and inspired me to write this article. Many of the CSModules below includes the source code in the download, so if you are a developer, you can see examples on how different things can be done in a CSModule.

Other articles on CSModules
Documentation
Downloadable CSModules
Misc. Tools for CSModules

 

Summary

In this article you have been presented with an overview of what a CSModule is and how it relates to Community Server. I have also talked about the basic steps for creating and installing them, how you can add interactivity to them, and a list of resources to learn more.

If you think I have forgotten some important resource, please leave a comment, and I might update this article.

P.S. Look out for a new release of the CS MVP CSModule pack in a near future, with some additional CSModules (including source code) and a few fixes to the existing modules!

Update 2006-11-03:

Corrected the link to CSApplication events which incorrectly pointed to CSModules. Thanks Robert A for pointing that out!

If you enjoyed this post Subscribe to my feed via RSS or e-mail!
Posted: Monday, October 30, 2006 7:43 PM by J-O Eriksson

Comments

Tim Laughlin said:

Another fine post for those of us just starting with CS.  Much appreciated.

# October 30, 2006 12:40 PM

Community Server Daily News said:

news of the day a grab bag for what's happening in Community Server This is Rick Reszler's first day

# October 30, 2006 2:13 PM

Keyvan Nayyeri said:

J-O Eriksson had done a nice job on putting a link to voice version of one of his blog posts. This MP3

# October 31, 2006 12:23 AM

Community Server Daily News said:

news of the day a grab bag for what's happening in Community Server Wyatt Preul, like Ben, is in suspense

# November 3, 2006 2:40 PM

Announcements said:

This week... The Community Server 2.1 Service Pack 1 is released! BlogMailr is announced! Well, sorta.

# November 6, 2006 6:41 AM

Rob Holmes said:

A great help - many thanks.

# November 9, 2006 2:22 AM

J-O Eriksson said:

Great to hear that it was helpful Rob!

# November 9, 2006 5:39 PM

J-O Eriksson said:

And the same to you Tim!

# November 9, 2006 5:41 PM

Community Server said:

This week... The Community Server 2.1 Service Pack 1 is released! BlogMailr is announced! Well, sorta.

# January 19, 2007 7:52 PM

Julius Ganns said:

Hi Guys, I found a really great development article about CommunityServer. Have a look at the following

# March 4, 2007 6:55 AM

Community Server Bits said:

Whew, that was so close! We thought we would have to go to press without a report from our news affiliate

# March 12, 2007 5:30 AM

My Blog said:

Well, I have been spending some time getting this site setup like it was in the not too distant past,

# March 21, 2007 2:59 AM

芝麻小站 said:

# March 25, 2007 6:28 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS