I approached a series as a LinkCategory object with a new SeriesCollection CategoryType. The LinkCategory is a reusable and versatile data object in .Text 0.95. Very smart design from ScottW! The CategoryTypes are shown below, where you can see the same LinkCategory object used with posts, stories, images, and archives.
public enum CategoryType
{
LinkCollection = 0,
PostCollection =1,
StoryCollection =2,
ImageCollection =3,
ArchiveMonthCollection = 4,
SeriesCollection = 5,
Undeclared = 999
}
I extended the LinkCategory object by added a ParentCatID int and ParentTitle string properties, since Series Collections are logical children of a Category. This also required adding a ParentCategoryID to the blog_LinkCategories table, a CategoryType field to the blog_Links table, and updating SQL stored procs and data provider methods accordingly.
Since Series was another LInkCategory type, to generate the Series collection in the sidebar along with Categories and Archived Months I only had to add it to the LinkCategory collection being bound to the menu repeater controls in CategoryList.ascx. CategoryList UserControl was called from SingleColumn.ascx, where the collection below was populated and passed to CategoryList.ascx by CategoryType.
LinkCategoryCollection lcc = new LinkCategoryCollection();
string fqu = CurrentBlog.FullyQualifiedUrl;
lcc.Add(UIData.Links(CategoryType.StoryCollection,CurrentBlog.UrlFormats));
lcc.Add(UIData.Links(CategoryType.PostCollection,CurrentBlog.UrlFormats));
lcc.Add(UIData.Links(CategoryType.ImageCollection,CurrentBlog.UrlFormats));
lcc.AddRange(Links.GetActiveCategories());
lcc.Add(UIData.ArchiveMonth(CurrentBlog.UrlFormats));
lcc.Add(UIData.Links(CategoryType.SeriesCollection,CurrentBlog.UrlFormats));
An interesting aspect of generating the menus was generating the links. The URLs were generated in the Dottext.Common namespace's Transformer class. Before I show that I'll mention that the URLs for the pages displaying Posts by Series had to be added to the web.config HttpHandler section. Since Series is just another LinkCategory Collection type, I added it to the existing pattern for categories and stories.
<HTTPHANDLER pattern="^(?:\/(\w|\s|\.)+\/(?:category|stories|series)/(\w|\s)+\.aspx)$" controls="CategoryEntryList.ascx" />
Now it can be processed in the Transformer class, which calls the methods in UrlFormats, where a Series URL format was added.
public static LinkCategory BuildLinks(string Title, CategoryType catType, UrlFormats formats)
{
LinkCategoryCollection lcc = Links.GetCategories(catType,true);
LinkCategory lc = null;
if(lcc != null && lcc.Count > 0)
{
lc = new LinkCategory();
int count = lcc.Count;
lc.Title = Title;
lc.Links = new LinkCollection();
Link link = null;
for(int i = 0; i {
link = new Link();
link.Title = lcc[i].Title;
link.CategoryID = lcc[i].CategoryID;
switch(catType)
{
case CategoryType.StoryCollection:
link.Url = formats.ArticleCategoryUrl(link.Title,lcc[i].CategoryID);
break;
case CategoryType.SeriesCollection:
link.Url = formats.PostSeriesUrl(link.Title,lcc[i].CategoryID);
break;
case CategoryType.PostCollection:
link.Url = formats.PostCategoryUrl(link.Title,lcc[i].CategoryID);
link.Rss = link.Url + "/rss";
break;
case CategoryType.ImageCollection:
link.Url = formats.GalleryUrl(link.Title,lcc[i].CategoryID);
break;
}
link.NewWindow = false;
lc.Links.Add(link);
}
}
return lc;
}
Then to UrlFormats in the Dottext.Framework.Format namespace
public virtual string PostSeriesUrl(string categoryName, int categoryID)
{
return GetUrl("series/{0}.aspx",categoryID);
}
Now that we've created the series collection menu and URLs, we can display the page to list all post entries by series, just as we do for posts by categories. Remember our web.config entry?
<HTTPHANDLER pattern="^(?:\/(\w|\s|\.)+\/(?:category|stories|series)/(\w|\s)+\.aspx)$" controls="CategoryEntryList.ascx" />
Series is just another LinkCategory collection type, so the work here has already been done and no further changes were required to display post entries by Series.