I decided to put together a BlogEngine extension that will display the top posts based on the number of comments they’ve received. I’ve been wanting this extension for a long while, and I decided to bite the bullet and put it together myself.
Why isn’t there a Top Post class for BlogEngine?
I’ve looked around quite a bit for this component and to my surprise, I never found one. The closest I’ve come to something similar is Cristiano Fino’s Top Commenters component for BlogEngine. After the amazement of not finding an existing component wore off, I decided to put one together.
Mind you, I’m still getting comfortable working within BlogEngine, and each time I do I learn a little more about the engine itself. If this extension could benefit from any code changes, please let me know.
My main point of concern is the way I refer to the Posts collection. You’ll see in the following code snippet that I define a new List collection of Post objects. I then needed to sort the collection to obtain the top commented posts that define the top posts to obtain. So, to not effect the ordering for anything that may use the collection later, I make a copy of the collection and sort that instead.
// Make a copy of the posts collection so that it doesn't impact normal rendering // after we sort it List<Post> posts = new List<Post>(); posts.AddRange(Post.Posts); // Sort the items based on number of comments posts.Sort(delegate(Post post1, Post post2) { return Comparer<int>.Default.Compare(post2.Comments.Count, post1.Comments.Count); });
If this method can be improved or done in a way that is more efficient, please let me know.
Why the Top Posts Extension?
I wanted this extension for a few reasons. The foremost being that I wanted to highlight some of the more popular posts found on my blog (if you can define comment count as popular). I wanted new readers to be able to see some of the more active posts within the archives. I decided display the top 5 commented posts.
Another reason was to punch through an extension for BlogEngine. I’ve been sitting on doing one for a long while now, and I finally found the time and drive to bust this out.
Finally, I also wonder if this will be included in the core. I find it remarkable that it isn’t there already. Perhaps this will inspire the devs to include it?
Implementing the Top Posts Extension
Implementing the extension is easy. Simply copy the TopPost.cs file to your App_Code/Extensions folder. Once there, you can then place the following in your site.master theme file:
<blog:TopPosts MaxNumber="5" ID="TopPosts1" runat="server" />
MaxNumber – The number of posts to display
Download the Top Posts Extension
I know this will work for BE 1.3 or greater…
Single file in a zip – Download TopPosts.zip (2kb)
I’ve also put a Download page in place to capture any future extensions or themes I might put together.
Feature Requests
Modifying the control may be easy for some, and not so for others. If there are any changes you think would be good to include, leave a comment and let me know. I’d be happy to work them in for you.
You might also enjoy these related posts
- BlogEngine.net Themes Now Available On BlogEngineTheme.com You might be wondering where I’ve been these past few weeks. My posts have been slow to come out, and the dark rings around my eyes have become even more...
- Top Droppers Listing Control for BlogEngine I’ve been using EntreCard for some time now, and I really enjoy finding new blogs through their network. I tried to find a widget I could use to create a...
- BlogEngineTheme.com Extensions I’m in a bit of a quandry over what to do with the extensions over on BlogEngineTheme.com. I have a couple extensions that I’d like to put up, but I’m...
- Theme Creation – BlogEngine.NET Wiki This theme creation page is written for BlogEngine. Since I recently switched this site to BlogEngine from DotNetNuke, I'll need to refer to this page a little bit. Theme Creation...
- Drag Queens, Cloggers, Frogs Legs, and BlogEngine.net, oh my! Four things you never thought you would see in the same sentence. I swear there’s a reason for the title, you only need to read on to figure it out....

Just wanna say thank you for the information that you have been shared webmaster! Keep it up!
your is very informative thanks for sharing i learn also something in your blog.,
thanks , i learn something new here
There are a few good resources out there, the first and foremost is the codeplex forum. Do a google for anything BlogEngine and you’ll find plenty of material.
You should know a little about the .Net framework though….
actually i am interested to use blogengine, but sadly not enough tutorial i found
@Demeur – Yeah, I either need to control that up front when you enter your name, or on the back-end when I display the list. I’ve been eyeballing that for some time and considering which way would be best to handle it.
I’ve noticed that a lot recently. I’ll watch things and simply consider them for a bit, and then BAM, correct it one day.
I like to see who’s been blabbing but I think I’d have to change the margins on my blog and I’ve just been too lazy of late. Also I see that names are case sensitive. There’s two of me in the top comments. D and d
@Muhammad – Yeah, that would be the next step for it. Although, I don’t make use of the widget functionality found in BE yet. In fact, I removed it. I wanted to work with each control individually and not have to have them all in a “single line” as well.
When BE went widgets, I was only 4 months in to learning BE, so I have much to learn before I dig into that. Like I said though, that would be the next logical step for this.
If you have the bandwidth for that, feel free to take it and mod it into a widget. I for one, am stretched a bit thin.
That is cool [b]Wayne[/b] my friend. But Also you can implement it as widget instead of adding the control to master page! what do you think?