More in this section
Blogs RSS feed

Archive control for Sitefinity blogs

by User Not Found
This post will explain how to implement archive functionality in Sitefinity blogs, similar to the one you can see on this blog. The idea is pretty simple. We want to list all the months in a year and show many posts have been published in that month, regardless of how embarrassing sometimes that can be (take June or April on this blog for example). When user clicks on a link we want to display the list of posts published in that month.

Not in a reading mood? Download the controls right away!

Page structure

To archive this you'll need three different pages in your blog. Take a look at the graphic below to see what I mean.

Pages / controls structure of archives functionality
As you can see there are three different pages that we have :
  • All posts page - this is a page where you will put two (at minimum) controls. The standard PostList control and Archive control (it is a user control which you can download at the bottom of this post)
  • Single post page - this page has also two controls. The standard SinglePost control and again Archive control
  • Archive posts page - this is the page that will display only posts published in a particular month of a year. Instead of using a standard PostList control you will use here ArchivePostList control, which is a user control that wraps up standard PostList control and alters it's data source to show appropriate posts.


As you may have already noticed, I have mentioned two controls that do not come with standard Sitefinity installation. These are the two user controls I have built to archive this functionality.

Archive control

Archive control is the control you will have pretty much on every page. It displays month and year together with the number of posts published in that month. There are two important properties of this control :
  • SelectedBlogs - determines for which blog(s) will archive be created. This allows you to have different archive controls for each blog and maybe one control that creates archive for all blogs on your site.
  • ArchivePageUrl - this property sets the url of a page where you have put ArchivePostList control. This property is very similar to the ExternalSinglePostPage property of standard PostList control. Basically, you are telling control where to go when the month link is clicked.

ArchivePostList control

This control is a user control which only purpose is to wrap the standard PostList control and modify it's data source to show only posts published in a particular month. There is only one property in this control, though you can modify the control to expose more of the PostList control's properties.
  • ExternalSinglePostPage - this property determines the page which contains SinglePost control or in other words, where should you go when you click on the post inside of the list.


All in all it's pretty simple functionality. You will notice in the ArchivePostList control how to take advantage of the newly introduced property CustomDataSource. The two mentioned controls are commented and you can download them from here.


Leave a comment
  1. Ben Jul 14, 2007
    Works great. Have you seen the tags though?
  2. Tim Oct 26, 2007
    Unable to cast object of type 'Telerik.Blogs.Configuration.GenericContentElement' to type 'Telerik.Blogs.IBlogProvider'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidCastException: Unable to cast object of type 'Telerik.Blogs.Configuration.GenericContentElement' to type 'Telerik.Blogs.IBlogProvider'.
  3. PRABAKARAN G Jun 15, 2011
    Hello pls

    Need a little bit help..I have two usercontrols in a page. I want see second user control while the first user control is in hide.,vice versa..

    shall i have to type code in usercontrol or set any property in page..

    Could send code for this,..pls help

    Leave a comment