Adding a "Hosted Blogs" Item to Community Server Homepage
Posted
Saturday, January 26, 2008 1:27 PM
by
Kevin
Looks like I already have an opportunity to blog about an unexpected topic - Community Server! When we switched the DotNetMafia site over to CS2007, the first thing I realized that we needed was a new theme. Nothing against the default, but it's pretty generic and doesn't really say "mafia" to me. :)
Theming CS2007 could merit a blog in and of itself (in fact, http://getben.com/ and http://community.hydrussoftware.com/blogs/jeffesp/default.aspx both appear to touch on the subject quite regularly). So I'll leave most of the details to them. But I was proud enough of myself for figuring out how to add a list of blogs to the homepage that I decided to write a quick blog post about it.
First, you'll need to start with a custom theme. Get|Ben has a good post covering the process of creating a new theme here. For this post, I'll assume you're starting with a copy of the default theme. Inside your theme's folder, there is a Common folder containing the master pages as well as the homepage (home.aspx) for your site. Open the homepage and scroll to the bottom of the file. In my case, I wanted to add the blog list as a "bubble" on the sidebar - similar to the tag cloud that was already there. At the bottom of home.aspx, you can see the <CSControl:TagCloud runat="server"... tag. I inserted some "hello world" text below that, saved the file, and brought up my site's homepage. Sure enough, that's where I want my blog list.
So - how's it done? If you're going to mess with theming much, you will want to download a copy of the Community Server 2007 Chameleon Control API help file. I found it on the Community Server site here. What's not immediately obvious when you open this help file is that the CSControl, CSBlog, CSForum, etc tag prefixes relate to the CommunityServer.Controls, CommunityServer.Blogs.Controls, etc namespaces documented within this file (the tag prefixes are registered in CS2007's web.config file if you're curious). Anyhow, what I did was look through this help file for something that looked like a blog list. What I found was CommunityServer.Blogs.Controls.WeblogList. Could it be that simple? I went back to home.aspx and replaced my "hello world" with <CSBlog:WeblogList runat="server" /> and refreshed my browser. Sure enough, now I have a list of the site's blogs!
Ok well, it's just a bullet list and still doesn't look like a "bubble" like the other stuff in the sidebar. It was a pretty simple matter of looking at the CSS used in the TagCloud control above to come up with this:
<div class="CommonSidebarArea">
<div class="CommonSidebarRoundTop"><div class="r1"></div><div class="r2"></div><div class="r3"></div><div class="r4"></div></div>
<div class="CommonSidebarInnerArea">
<h4 class="CommonSidebarHeader">Our Blogs</h4>
<div class="CommonSidebarContent">
<CSBlog:WeblogList runat="server" />
</div>
</div>
<div class="CommonSidebarRoundBottom"><div class="r1"></div><div class="r2"></div><div class="r3"></div><div class="r4"></div></div>
</div>
And voilĂ , a blog list in a bubble.
I hope to do some more cool stuff with Community Server themes as I find the time. If I do, I'll be sure to write about it here!