As you may notice I don’t use categories in my blog, only tags. Whether it’s good or bad – is a matter of another topic.  Now I’m going to talk about how to make the archive work properly if you don’t have any categories, because it doesn’t display any posts unless they are filed under some category. I hope this will be fixed in the next versions, but you can fix it yourself, it’s not difficult.

Open archive.aspx.cs, find the Page_Load() method and remove the line containing CreateMenu() that we don’t need, because this function just prints the list of the categories, but we don’t have any. Then, go to the CreateArchive() method. Can you see that it only returns the posts assigned to some category? That’s no good, just remove the foreach statement and change Post.GetPostsByCategory() to Post.Posts that will just return all the posts, no matter whether they belong to a particular category or not.

So, CreateArchive() should look like this:


private void CreateArchive()
  List<Post> list = Post.Posts;

  HtmlTable table = CreateTable("");

  foreach (Post post in list)
            if (!post.IsVisible)

    HtmlTableRow row = new HtmlTableRow ();

    HtmlTableCell date = new HtmlTableCell();
    date.InnerHtml = post.DateCreated.ToString("yyyy-MM-dd");
    date.Attributes.Add("class", "date");

    HtmlTableCell title = new HtmlTableCell();
    title.InnerHtml = string.Format("<a href=\"{0}\">{1}</a>", post.RelativeLink, post.Title);
    title.Attributes.Add("class", "title");

    if (BlogSettings.Instance.IsCommentsEnabled)
      HtmlTableCell comments = new HtmlTableCell();
      comments.InnerHtml = post.ApprovedComments.Count.ToString();
      comments.Attributes.Add("class", "comments");

    if (BlogSettings.Instance.EnableRating)
      HtmlTableCell rating = new HtmlTableCell();
      rating.InnerHtml = post.Raters == 0 ? "None" : Math.Round(post.Rating, 1).ToString();
      rating.Attributes.Add("class", "rating");




archive.aspx.cs (4.62 kb)