CS Tidbits #27: Add An Archive Page For Blogs

It's been a while since I've posted any CS Tidbits, but now that Community Server 2008.5 has been released, it's time to get back in gear and post some tips and tricks that I'm learning as I get to know this new release.

If you're like me and have been blogging for a non-trivial amount of time (over 5 years in my case), an archived list view of your posts starts to look a bit unwieldy. CS 2008.5 does ship with an archive widget to display in your blog's sidebar, however this will lead to a long page length, and doesn't look as tidy as it could if the archive list could live in its own page. Fortunately for us, adding a dedicated archive page is easy enough. First, create a blank .aspx page in your /themes/blogs/hawaii directory, and name it archive.aspx. Then just add the following markup to it:

<%@ Page Language="C#" AutoEventWireup="true" EnableViewState="False" MasterPageFile="theme.Master" Inherits="CommunityServer.Blogs.Controls.CSBlogThemePage" %> 
 
<asp:Content ContentPlaceHolderID="bbcr" runat="server">
    <div class="CommonBreadCrumbArea"><div class="Common">
        <CSBlog:WeblogData Property="Name" LinkTo="HomePage" runat="server" />
        &raquo;
        <CSBlog:WeblogData LinkTo="archive" runat="server" Text="Archive" />
    </div></div>
</asp:Content> 
 
<asp:Content ContentPlaceHolderID="tr" runat="server">
    <CSControl:Title runat="server" IncludeSectionOrHubName="true" IncludeSiteName="true" EnableRendering="true" Tag="H1" CssClass="CommonTitle">
        <ContentTemplate><CSBlog:WeblogData runat="server" Text="Archive" /></ContentTemplate>
    </CSControl:Title>
</asp:Content> 
 
<asp:Content ContentPlaceHolderID="bcr" runat="Server"> 
 
    <div class="CommonContentBox">
        <div class="CommonContentBoxContent">
            <CSBlog:ArchiveDataItemList runat="server" />
        </div>
    </div>
</asp:Content>

That should be all you need to do as the URL for the page is already wired up correctly in your SiteUrls.config file by the following line:

<url name = "weblogarchive"  path="##blogdirectory##archive.aspx" pattern="##blogName##/archive.aspx"  physicalPath="##blogthemeDir##" vanity="{2}?App=${{app}}" page="archive.aspx" indexable="false" />

To view the newly created archive page, navigate to <yourSite>/blogs/<blogName>/archive.aspx. Of course you'll want to add a link to this somewhere on your blog. I'll cover how to create a nested navigation bar for blog links in a future CS Tidbit post.

Filed under:

Comments

# Terry Walker said:

That’s great, I never thought about Add An Archive Page For Blogs like that before.

Monday, January 19, 2009 2:14 AM
# Shaun Davis said:

Hey just a heads up, I wanted to let everyone know that Xio Dibin speaks English.  I hope I posted in the right location?

Wednesday, April 22, 2009 11:24 PM