Graffiti CMS Archives Widget

Some blog engines provide a way to list the number of posts you've made in a given month.  Graffiti CMS doesn't provide this functionality out of the box, but fortunately, the extensibility API is very powerful.  This post briefly describes how to configure the Archives widget.

The source code targets .NET 2.0.  The solution and project files were created with Visual Studio 2008.

You can download the source here: Sagara.GraffitiExtensions.zip

 Configuration

  1. The first thing you'll need to do is build the source.  Note that you'll need to have a local copy of Graffiti somewhere on your disk so that you can reference the Graffiti binaries from the Visual Studio Project file.

    To make things easy on myself, I created a rule to copy the resulting binary into my local Graffiti installation's bin directory.  You will need to edit this path to match your environment.
     
  2. If you don't have your build set up to automatically copy Sagara.GraffitiExtensions.dll into your local Graffiti installation's bin directory, you must manually copy it over.
     
  3. You'll need to create a new page for your theme called "archive.view".  (1) Log into your Graffiti control panel, and select Presentation -> Themes.   (2) For your currently selected theme, click on "Personalize".  (3) Click on "Create New File", and then give the new file the name archive.view. 

    The actual contents of this new file depends on how you want to display your archived posts.  A good template to use is your existing index.view page.  The important thing to note is that instead of using "#foreach($post in $posts)" to retrieve your posts, you'll use the new Archives Chalk extension instead: "#foreach($post in $postArchive.GetPostsByYearMonth($request.year, $request.month))". 

    There is also a function to allow you to display the Month and Year of the selected archives page: "$postArchive.DisplayMonthYear($request.Year, $request.month)"

    If none of this makes much sense, see the sample archive.view I have included in the source code.  :)
     
  4. Next, you'll need to enable the Cache invalidator plug-ins.  Do this by going to Site Options -> Plug-Ins.  You'll see two plug-ins whose names start with Sagara.GraffitiExtensions.Plugins.  Unfortunately, the names run into the links, so you can't really see what the links say, but just click on the links to enable both plugins.

    These plugins update the cached archives objects any time the user inserts or updates a post.  At this time, Graffiti does not expose the delete event, so the cache automatically expires after 10 minutes.
     
  5. You'll need to create a new, uncategorized post named "archive".  Click on Write, and then give the post a title of archive.  For the body, you can type in any dummy text you like as it won't be displayed.  The archive.view from step 3 will be shown in its place.
     
  6. Finally, you'll need to enable the Archive widget so that it displays in your sidebar.  Go to Presentation -> Widgets.  From Available Widgets, select the one named "Archives", and drag it onto the appopriate Sidebar box (left or right). 

That should be it.  If not, let me know, and I'll see what I can do.

Enjoy!

Options:

Size

Colors