Brendan Tompkins

Sponsors

The Lounge

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Community Server Homepage Controls

If you read us through our website, you’ve probably noticed that we launched our new homepage yesterday. Community Server didn’t have exactly the controls I needed to create the new homepage, so I had to create new controls that did what I wanted.  Fortunately, CS did gave me the building blocks I needed to quickly assemble the new page.  I wanted to post here the source files, in case anyone wants to create a similar page with Community Server. I created three new controls.  Here’s what they look like on the home page.

Control 1:   FeaturedArticle
Purpose: This control shows one featured article, along with the excerpt and the author’s avatar.
Files Needed : FeaturedArticle.cs, Skin-FeaturedArticle.ascx

Control 2:   AggregateCompactPostList
Purpose: Shows a configurable number of latest and most popular posts.
Files Needed : AggregateCompactPostList.cs, Skin-AggregateCompactPostList.ascx, AggregatePostList.cs, AggregatePostList.ascx

Control 3:   AggregateCompactArticleList
Purpose: Displays an article’s category title, excerpt, and published articles.
Files Needed : AggregateCompactArticleList.cs, Skin-AggregateCompactArticleList.ascx, AggregatePostList.cs, AggregatePostList.ascx

You’ll also need some css styles added to CommunityServer’s style sheet (via default.aspx in the Themes/default/style directory)

All CS files go in the CommunityServerBlogs project in the Controls/AggregateBlogControls directory, and all ascx files go in the CommunityServerWeb project in the Themes/Default/Skins/Blogs directory.

You can download the source files here.  Shoot me an email if you need help implementing this, or if I left anything out.

-Brendan


Posted Wed, Jun 15 2005 7:30 AM by Brendan Tompkins

[Advertisement]

Comments

David Hayden wrote re: Community Server Homepage Controls
on Wed, Jun 15 2005 8:52 AM
Absolutely, positively awesome, Brendan!
Steve wrote re: Community Server Homepage Controls
on Wed, Jun 15 2005 9:50 AM
Looks awesome! Nice work!
keithrull wrote re: Community Server Homepage Controls
on Wed, Jun 15 2005 10:24 AM
i'd be interested to see those source codes! :) *wink* *wink*
Alex Lowe wrote re: Community Server Homepage Controls
on Wed, Jun 15 2005 10:25 AM
This is very cool!

I posted a note about it on the new Add-ons forum at CS.org.....

http://communityserver.org/forums/488637/ShowPost.aspx
John Papa wrote re: Community Server Homepage Controls
on Wed, Jun 15 2005 11:11 AM
Great work Brendan! Looks nice!
Scott wrote re: Community Server Homepage Controls
on Thu, Jun 16 2005 9:59 AM
Very nice. You're helping to make CS into a real, live boy!
swing wrote Help me pls! How can I get it works with CS1.1?
on Thu, Jun 16 2005 1:30 PM
When I follow the guidance, copy all .cs files into \src\Blogs\Controls\AggregateBlogControls and copy all .ascx files into \src\Web\Themes\Blogs...(right? ), then I open CS solution and add those files into, then recompile, there was two errors in AggregateCompactPostList.cs

Line 17 and line 175: Webblogs.GetWeblogGroup() and Weblogs.GetWeblogs() method have been change when upgrade from cs1.0 to cs1.1, so I modified these two lines, and I can go through compiling, but when I visit my new home page, there was an exception "skin file not found"

I still working on it, if someone done, please tell me what should I do, thanks
Brendan Tompkins wrote re: Community Server Homepage Controls
on Thu, Jun 16 2005 2:15 PM
Swing,

Skins for these aggregate controls go in the

Themes/default/Skins/Blogs directory. It was incorrect in the initial post, but I've updated it.

B
swing wrote Thank you!
on Thu, Jun 16 2005 5:45 PM
When I copy .ascx files to Themes/Default/Skins/Blogs directory, it runs pretty well, but line 144 & 175 in AggregateCompactPostList.cs need to change before compile with CS1.1.
Phosphorus wrote re: Community Server Homepage Controls
on Fri, Jun 17 2005 2:15 PM
I've been trying to implement these controls for the last day and a half, and I almost have it working properly.

Currently, I am hung up on getting the "Featured Article" control working.

In the default.aspx page that you supplied, the <Blog: FeaturedArticle/> control doesn't include any mention of a BlogId. Without the BlogId, the stored procedure is passed a 0, so nothing is ever returned.

I had to add this line:
query.BlogID = this.blogId ; (on line 137 of FeaturedArticle.cs)

and BlogId = "4"

to the <Blog:FeaturedArticle> tag in the aspx code.

Even after adding a BlogId = number element in the aspx, the stored procedure that is used to get the right article also looks for the "PostLevel" value in the cs_posts table.

The PostLevel field seems to correspond to the number of comments that have been posted about a given article. The strange thing is that the stored procedure (cs_weblog_Postset) will not return any records unless the PostLevel is not 1.

See the last line in the sproc:

SELECT @TotalRecords = Count(PostID) FROM cs_Posts (nolock) WHERE IsApproved = 1 AND ThreadID = @ThreadID and PostLevel <> 1

So basically, on a brand new article (with no comments), @TotalRecords will equal 0 (since PostLevel equals 1). FeaturedArticle.cs reads that @TotalRecords output paramater and when it sees that it is 0, it skips over the guts of the code that renders the post to the page.

Also, for others that are implementing these controls and end up with a "the requested resource could not be found" error on your default.aspx page, make sure you go into the .aspx and set the "BlogId" and "CategoryId" tags to valid values. You will have to poke around in your database to find them.
Phosphorous wrote re: Community Server Homepage Controls
on Fri, Jun 17 2005 2:23 PM
I should mention that I am using the 1.0 source, so that might be the cause of most of my problems.
Phosphorous wrote re: Community Server Homepage Controls
on Fri, Jun 17 2005 4:19 PM
I just upgraded to the 1.1 source and ran into the same issues that were mentioned above. Additionally, I had to comment out line 152 in featuredarticle.cs:

//this.authorLink.ImageUrl = we.User.AvatarUrl;

It seems that the User object is no longer available in that context. Will have to look into the new way of getting it.

Oh yeah, and the layout of the home page is different in 1.1, so the css gets messed up. But other than that, the other problems associated with PostLevel seem to have been fixed.
Brendan Tompkins wrote re: Community Server Homepage Controls
on Fri, Jun 17 2005 5:35 PM
Phosphorus,

Thanks for taking the time to look at this. I just started migrating to 1.1 today, and did see that the user object was removed from interface.

This would certainly be problematic for the Avatar.

Sorry about the other issues. Not sure why you were seeing this behavior. If I get anywhere, with 1.1 I'll re-post the code.

Hey, it worked on my machine. ;P
Brendan Tompkins wrote Community Server Homepage Controls 1.1 Update
on Wed, Jun 22 2005 6:58 AM
Last week, I posted the code for our Community Server Homepage Controls

Control 1: FeaturedArticlePurpose:...
Brendan Tompkins wrote Community Server Homepage Controls 1.1 Update
on Wed, Jun 22 2005 7:00 AM
Last week, I posted the code for our Community Server Homepage Controls

Control 1: FeaturedArticlePurpose:...
Off Shot Thoughts wrote Finally my controls are updated!!!
on Mon, Jun 27 2005 3:08 PM
After much messing around and getting the main page for this sitelooking like I want, I think I'm ready...
Off Shot Thoughts wrote Finally my controls are updated!!!
on Mon, Jun 27 2005 3:09 PM
After much messing around and getting the main page for this sitelooking like I want, I think I'm ready...
Off Shot Thoughts wrote Finally my controls are updated!!!
on Mon, Jun 27 2005 3:12 PM
After much messing around and getting the main page for this sitelooking like I want, I think I'm ready...
Off Shot Thoughts wrote Finally my controls are updated!!!
on Mon, Jun 27 2005 3:14 PM
After much messing around and getting the main page for this site looking like I want, I think I'm ready...
Off Shot Thoughts wrote Finally my controls are updated!!!
on Mon, Jun 27 2005 3:17 PM
After much messing around and getting the main page for this site looking like I want, I think I'm ready...
Off Shot Thoughts wrote Finally my controls are updated!!!
on Mon, Jun 27 2005 3:17 PM
After much messing around and getting the main page for this site looking like I want, I think I'm ready...
Off Shot Thoughts wrote Finally my controls are updated!!!
on Wed, Jun 29 2005 3:39 PM
After much messing around and getting the main page for this site looking like I want, I think I'm ready...
Off Shot Thoughts wrote Finally my controls are updated!!!
on Sun, Jul 3 2005 2:04 AM
Community Server,Web,Development,Blogs
Off Shot Thoughts wrote Finally my controls are updated!!!
on Sun, Jul 10 2005 1:34 AM
Community Server,Web,Development,Blogs
Off Shot Thoughts wrote Finally my controls are updated!!!
on Sun, Jul 10 2005 1:40 AM
Community Server,Web,Development,Blogs
Off Shot Thoughts wrote Finally my controls are updated!!!
on Sun, Jul 10 2005 1:40 AM
Community Server,Web,Development,Blogs
Off Shot Thoughts wrote Finally my controls are updated!!!
on Sun, Jul 10 2005 1:42 AM
After much messing around and getting the main page for this site looking like I want, I think I'm ready...
Off Shot Thoughts wrote Finally my controls are updated!!!
on Sun, Jul 10 2005 1:43 AM
After much messing around and getting the main page for this site looking like I want, I think I'm ready...
Off Shot Thoughts wrote Finally my controls are updated!!!
on Sun, Jul 10 2005 10:11 PM
After much messing around and getting the main page for this site looking like I want, I think I'm ready...
Kevin Dan's Blog wrote Together.blogdns.com Website is Up and Running
on Fri, Aug 19 2005 1:27 PM
Not with a little twist, Together.blogdns.com ( a newly registered domain name) can be reached all over...
Kevin Dan's Blog wrote Together.blogdns.com Website is Up and Running
on Fri, Aug 19 2005 1:28 PM
Now with a little twist, together.blogdns.com (a newly registered domain name) can be reached all over...
Nix's Blog wrote MIGRATION DES BLOGS DE .TEXT A COMMUNITYSERVER 1.1
on Fri, Oct 21 2005 6:34 AM
Les blogs CodeS-SourceS viennent d'&#234;tre migr&#233; sur CommunityServer. (Peut-&#234;tre avez-vous remarqu&#233; un &quot;l&#233;ger&quot;...
Nix's Blog wrote MIGRATION DES BLOGS DE .TEXT A COMMUNITYSERVER 1.1
on Fri, Oct 21 2005 6:35 AM
Les blogs CodeS-SourceS viennent d'&#234;tre migr&#233; sur CommunityServer. (Peut-&#234;tre avez-vous remarqu&#233; un &quot;l&#233;ger&quot;...
Nix's Blog wrote MIGRATION DES BLOGS DE .TEXT A COMMUNITYSERVER 1.1
on Fri, Oct 21 2005 8:54 AM
Les blogs CodeS-SourceS viennent d'&#234;tre migr&#233; sur CommunityServer. (Peut-&#234;tre avez-vous remarqu&#233; un &quot;l&#233;ger&quot;...
Nix's Blog wrote MIGRATION DES BLOGS DE .TEXT A COMMUNITYSERVER 1.1
on Thu, Oct 27 2005 3:17 PM
Les blogs CodeS-SourceS viennent d'&#234;tre migr&#233; sur CommunityServer. (Peut-&#234;tre avez-vous remarqu&#233; un &quot;l&#233;ger&quot;...
Jacob Reimers' Weblog wrote Featured Article and Aggregate List controls
on Mon, Mar 6 2006 7:54 AM
I adapted the Featured Article and AggregateCompactList to User Controls from Brendan Tompkin's originals and added them to the file list.
Jacob wrote re: Community Server Homepage Controls
on Mon, Mar 6 2006 7:57 AM
I posted an adaptation of your Featured Article and AggregateCompactList at http://www.reimers.dk/blogs/jjrdk/archive/2006/03/06/113.aspx

Your controls looked great, but didn't work for CS v 2.0 so I adapted them to User Controls.
Hope you approve.
Brendan Tompkins wrote re: Community Server Homepage Controls
on Mon, Mar 6 2006 8:43 AM
Jacob.. Thanks for this, very cool! BTW, you can get the source for CS2 in the SDK.

Brendan
Brendan Tompkins wrote CodeBetter.Com 2.0 and New Community Server HomePage Controls for Download
on Mon, Mar 20 2006 12:15 PM
This weekend we upgraded to Community Server 2.0 here at CodeBetter.&amp;nbsp;&amp;nbsp;We have a new improved...
murat wrote re: Community Server Homepage Controls
on Sun, Dec 31 2006 3:04 PM

I tried everything but it reteurns error like this:

-----------------------------------------------------

[NullReferenceException: Object reference not set to an instance of an object.]

  CommunityServer.HomePageControls.FeaturedArticle.DataBind() +129

  CommunityServer.HomePageControls.FeaturedArticle.OnLoad(EventArgs e) +50

  System.Web.UI.Control.LoadRecursive() +47

  System.Web.UI.Control.LoadRecursive() +131

  System.Web.UI.Control.LoadRecursive() +131

  System.Web.UI.Control.LoadRecursive() +131

  System.Web.UI.Control.LoadRecursive() +131

  System.Web.UI.Control.LoadRecursive() +131

  System.Web.UI.Control.LoadRecursive() +131

  System.Web.UI.Control.LoadRecursive() +131

  System.Web.UI.Control.LoadRecursive() +131

  System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061

--------------------------------------------------

justin wrote re: Community Server Homepage Controls
on Fri, Apr 13 2007 9:35 AM

Does this work with 2007 version of CS?

AlexNC wrote re: Community Server Homepage Controls
on Thu, Jun 7 2007 3:38 PM

Thank you so much for sharing this!!!

Pgvemmum wrote re: Community Server Homepage Controls
on Tue, Jul 14 2009 9:06 PM

YaxjKk

Add a Comment

(required)  
(optional)
(required)  
Remember Me?