Main | CatCalendar 0.3 Released »

CatCalendar

What is this plugin for?

Sooner or later almost every MT blog becomes buried beneath the weight of its own category archives. CatCalendar allows you to split up your blog's category archives into daily, weekly, or monthly archives.

Table of Contents

  1. CatCalendar Compatibility
  2. Installing CatCalendar
  3. Setting up a new archive
  4. Changing your old category archive template
  5. An sample template
  6. Template tags
  7. Configuration options

Compatibility

CatCalendar has been tested with MovableType 3.2 - 3.34. This plugin works only for statically published archives.

Installing CatCalendar

Download and unzip CatCalendar-0.6.zip. Put the directory CatCalendar-0.6/plugins/CatCalendar in your plugins directory.

CatCalendar is currently in beta, use it at your own risk. While in beta, it is for personal, non-commercial use only. Please email me if you'd like to use it in some other fashion.

Setting up a new date-based category archive.

  1. Go to the Settings page for your weblog and click on the Publishing tab (if you don't see this tab, click the "Switch to Detailed Settings" link on the top right of the settings page.)
  2. Scroll down to the "Archive Mapping" section of the page and click "Create New Archive Mapping".
  3. Pick your new date-based category type from the "Archive Type" drop-down.
  4. Pick a template from the "Template" drop-down. You can use your existing Date-Based Archive template, it'll do just fine.
  5. Click "Add".
  6. Important: When the page comes back up, take a look at the new archive mapping you've created, and click "Save Changes" at the bottom of the page.

Changing your old Category Archive template.

If you have already have category archives setup, you'll probably want to change the template to limit the number of entries that it displays. You might also want to include an archive listing below it:

<MTEntries lastn="15">
	...	
</MTEntries>

<ul>
<MTCategoryArchives type="Category-Monthly">
	<li><a href="<$MTArchiveLink$>"><$MTArchiveTitle$></a></li>
</MTCategoryArchives>
</ul>

Or perhaps you'd just like to redirect your category archive to the most recent archive for the category. If your weblog is hosted in an environment with PHP, you might try something like:

<?PHP 
    header('Location: '.
        <MTCategoryArchives type="Category-Monthly" lastn="1">
        '<$MTArchiveLink$>'</MTCategoryArchives>);
    exit;
?>

Template Tags

CatCalendar uses Movable Type's normal archive template tags. You can use just about any of the MTArchive* (except the MTArchives container tag) and MTCategory* tags. Plus, these tags added in CatCalendar:

MTCategoryArchives

A container tag that creates a context for each of the date archives for a category.

Attributes:

  • type - Specifies the type of date archive to list. One of "Category-Daily", "Category-Weekly", "Category-Monthly"
  • lastn - Optionally specifies a limit.
  • order - Specifies the sort order. One of 'ascend', 'descend'. Default is 'descend'.

MTArchiveFirst

Creates a context for the first (earliest/oldest) date-based archive for the current category.

MTArchiveLast

Creates a context for the last (most recent) date-based archive for the current category.

MTIfCategoryArchivesEnabled

Evaliuates whether date based archiving has been turned off for the current category. (See the configuration settings for more info.)

Template Example

Here is a good suggestion from Byrne for customizing your category archives

Put this at the top of your category-date archive template:

<h2>You are browsing the <$MTArchiveTitle$> category</h2>
<div id="menu">
<MTArchivePrevious><a href="<$MTArchiveLink$>">« <$MTArchiveDate
format="%B %Y"$></a> |</MTArchivePrevious>
<a href="<$MTBlogURL$>">Main</a>
<MTArchiveNext>| <a href="<$MTArchiveLink$>"><$MTArchiveDate format="%B
%Y"$> »</a></MTArchiveNext>
</div>

Put this in your category archive:

<h2>Recent Posts in <$MTArchiveTitle$></h2>
<MTEntries include_subcategories="1" lastn="2">
  <$MTEntryExcerpt$>
</MTEntries>

<h2>Browse this Category by Date...</h2>
<ul>
<MTCategoryArchives type="Category-Monthly">
  <li><a href="<$MTArchiveLink$>"><$MTArchiveDate format="%B
%Y"$></a></li>
</MTCategoryArchives>
</ul>

Rebuilding your archives

Just like Movable Type's native date-based and category archives, the appropriate archives will be automatically rebuilt when you save an entry.

If you want to rebuild all the date-based category archives for your blog, you can do it through the "Rebuild Site" link in the left-side navigation of your blog.

Configuration Options

CatCalendar will work just fine without you ever touching these. If you need some custom configuration, all the options are available in the blog-specific plugin settings

Rebuild adjacent archives

By default, CatCalendar will rebuild adjacent archives when an archive is rebuilt. I.e., if you save and entry that causes the March 2007 archive for your "Puppies" category to be rebuilt, CatCalendar will also rebuild the February and April archives. This is to preserve the ArchivePrevious and ArchiveNext links across the archives, though you may want to turn it off to speed up rebuilds.

Exclude categories

By default, CatCalendar will create archives for every populated category in your blog. If you have some categories that you do not need date-based archives for, you can do that here. This can be helpful if you have some categories with very few entries, or if you have certain categories that are for internal use.

TrackBack

TrackBack URL for this entry:
http://yacomink.com/cgi-bin/mt/mt-tb.cgi/589

Comments (33)

I can't tell you how awesome this plugin is. Your instructions are incredibly clear, and even I am amazed at how seamless the integration is. Good work.

Wow, this is great - do you have any idea if this will slow down my rebuilds? I have a massive site - 10,000+ posts...

Hi Nick,

Especially for a large site, this should speed up your rebuilds. A complete rebuild of your site may take slightly longer, but day to day rebuilds that happen when entries are saved should speed up. This is because only a small chunk of your category archives needs to be rebuilt at a time.

Nick:

I really want this to work, but I'm having the following issue:

Every time I do a site-wide rebuild, I get the following message in the rebuild window:

"Your date-based category archives still need to be rebuilt. Please click Rebuild Again and select these options individually."

So, I rebuild again, rebuilding the "Category-Monthly" archives seperately, it says it rebuilds them, but none of the pages every actually get created. Any ideas? (using MT 3.34)

nick:

Hi, so partially disregard that last message, the pages ARE being rebuily and created (was looking in the wrong spot, duh). However, I still get that weird error message everytime I rebuild. Any thoughts on that?

yacomink [TypeKey Profile Page]:

Hi Nick, it's not so much an error as an indication that you need to rebuild your category-date archives separately from the other MT archives. This may be addresses in a future version of CatCalendar.

billg:

Andy, here's a bug report on a great plugin:

When I delete all entries in a category, this error appears during the subsequent rebuild of category-monthly:

"Can't call method "blog_id" on an undefined value at /users/home/wagerrard/web/public/mt/plugins/CatCalendar/lib/RebuildMore/RebuildDispatch.pm line 172."

The index file that should be updated to reflect the deletions is not.

If I then create a new entry for that category, and rebuild category-monthly, I don't receive the error message and the index file is updated appropriately.

I also recall not being able to install an earlier version on a test site with no categories established. I created a category and then
installed it.

I'm on 3.34 and not using RebuildQueue.

billg

Does this work on v3.2?

yacomink [TypeKey Profile Page]:

I will be releasing an update in the next week or so that works with 3.2 as well as 3.3x

billg, that error should be fixed in 0.5

Hey Andy, fantastic little plugin you have here. Absolutely necessary... However, I may have found a bug. Tracing the code it seems so:

Under CatCalendar 0.5 and RebuildQueue 1.04 (latest revision, running in Daemon mode or from the command line), I'm getting the following error repetitively for each cat-monthly archive:

ERROR: Parameter 'Entry' is required

Do you know about this already?

Without RebuildQueue, I get no errors. Looking at the code I'm not sure why it's not returning from the RQ_Filter callback but I'll throw some debug statements at it to see what I can figure out.

Oh, that's under MT 3.35, btw.

yacomink [TypeKey Profile Page]:

Thanks Jay, I haven't seen that one before but I'll look into it.

I'm trying to do some date based archive stuff, and I can't figure out how to do this with CatCalendar. I posted about this over at the Sixapart forums with the link below. There's no point in rehashing here, just read this post for my story. Is what I'm trying to do even possible?

http://tinyurl.com/32alsc

Hey Andy, my head just exploded from trying to trace this bug. The problem is in a persistent environment, the value for MT::CallbacksEnabled{'RebuildQueue::ArchiveFilter'} is getting zeroed out when RebuildMore::RebuildDispatch::RQFilter is called and the right CatCalendar archive type is being built. This happens because of some recursion between RebuildQueue and CatCalendar. Here's the trace:

1. RebuildQueue::Publisher::rebuild_from_queue runs the RebuildQueue::ArchiveFilter callbacks
2. This executes RebuildMore::RebuildDispatch::RQFilter, returning normally unless the archive type is the specified CatCalendar type
3. In that case, RebuildMore::Publisher::rebuild_cat_archives_for_date is called to build the archive, DURING which of course, RebuildQueue's BuildFileFilter callback steps in and prevents it.

During the execution of the RebuildQueue::ArchiveFilter, the value for $MT::CallbacksEnabled{'RebuildQueue::ArchiveFilter'} is set to 0. That's normal, and for all other archive types it returns to 1 afterwards (see MT::run_callbacks). But, when the BuildFileFilter callback is called in the progress of the RebuildQueue::ArchiveFilter callback, it's value is still zero and PERSISTS at zero after they all return.

Sticky wicket this one. Not sure if I see these two getting along very well in a persistent environment. *sigh* I'm giving up while I still have some brain left...

By the way, just to be clear, I'm not really certain that this is your bug. In my mind, there's an equal chance that it could be a bug in either MT or RebuildQueue. The whole thing is too much of a mess for me to figure out at the moment.

Also, you can see some debugging output to illustrate what I mean at http://pastie.textmate.org/59101. This is a snapshot of the first run after FastCGI server initialization in rebuilding the Category-Monthly archive. The BEFORE and AFTER markers are at the beginning and end of MT::run_callbacks. The RMRDRQF marker is in RebuildMore::RebuildDispatch::RQFilter.

Note that the CALLBACK ENABLED value turns to zero. It stays that way indefinitely until server restart.

So, with my debugging output and a view of the code that produced it, Brad Choate found the problem.

In MT::run_callbacks, around line 376 in v3.34, there is the following loop: http://pastie.textmate.org/59169

In that loop, the $_ variable is being stepped on by, I am supposing, the recursion. By simple changing it to "for my $m (@methods)" and changing the one location of $_ in that loop, the problem is fixed.

So congratulations. Not your bug. I'm also not nuts. Well, at least not for this... :-)

Hi Andy -

Trying 0.5 on a 3.2 install, and I don't seem to get the category-monthly option to set up a new archive mapping. Any suggestions to make this happen? Thanks!

Rad [TypeKey Profile Page]:

Hi.

Can someone tell me *where* exactly this code goes?


...

I assume it goes in the Category archive, but *where* in the Category archive?

I noticed where Bryne said, "Your instructions are incredibly clear."

So I must be missing something obvious.

Rad [TypeKey Profile Page]:

It appears the code did not show up.

It is the snippet of code which appears imediately after this paragraph above:

If you have already have category archives setup, you'll probably want to change the template to limit the number of entries that it displays. You might also want to include an archive listing below it:

saahov [TypeKey Profile Page]:

Hi Andy,
After installation of a plugin it is necessary to make rebuild categories. But when I try it to make, there is such mistake:

"Can't call method "id" on an undefined value at /home/saahov/htdocs/cgi-bin/mt/plugins/CatCalendar/lib/RebuildMore/RebuildDispatch.pm line 146."

I use MT 3.34 and not using RebuildQueue.

Alana:

same error as 2 others above.. "Can't call method "id" on an undefined value at /path/to/mt/plugins/CatCalendar/lib/RebuildMore/RebuildDispatch.pm
line 146."

which seems to be here? (bold):

if ($start_entry_id && $start_entry_id)
{
# kick off this round of rebuilds
($cur_cid, $cur_eid, $done) = rebuild_pages( $app, $cat, $entry, $at, $pages );
}
else
{
# kick off this round of rebuilds
($cur_cid, $cur_eid, $done) = ($cat->id, $entry->id, 0);
}

I'm using MT 3.35

bjr:

Hello,

I'm usin MT 3.34 with CatCal 0.5

I'm getting some of these messages:
CatCalendar died with: Can't call method "status" on an undefined value at [snip]/plugins/CatCalendar/lib/RebuildMore/RebuildDispatch.pm line 35.

Can anyone give me a hint about this?

Thanks.

John:

71tERj 3v3445vtt075nvn0g8d0nb

Alan Barnard:

I've installed CC0.6 on an MT3.2 install, and the "category-monthly" option doesn't show up in the "Archive Type" drop down. Any suggestions?

Thanks-
Alan

bob:

bfPnMR hi nice site thx http://peace.com

Post a comment

0.6

  • Fixed nasty bug where MTArchiveLink was popping the entries stack, causing single-entry archives not to rebuild in some cases.
  • Fixed a problem with MTArchiveLink handler when used within a CategoryArchives block

0.5

CatCalendar 0.5 is out with a bunch of new stuff:

  • Config option for building of adjacent archives.
  • Config option to exclude some categories from CatCalendar rebuilds
  • IfCategoryArchivesEnabled template tag to detect above setting.
  • ArchiveFirst and ArchiveLast tags for CategoryArchives container
  • MovableType 3.2 Support
  • Better error handling for rebuilds and some template tags

0.4

This release addresses RebuildQueue rebuild and sync compatability by using a callback added to the most recent version of RebuildQueue. If you're using RebuildQueue, please get a fresh checkout, or add this snippet in RebuildQueue/lib/ RebuildQueue/Publisher.pm after line 17.

Download CatCalendar 0.4

CatCalendar 0.32

After a good amount of testing, this release should really make things work happily with RebuildQueue.

0.31

Another release for a few smallish bugs.

CatCalendar 0.3 Released

This is primarily a bugfix release. For a few people not seeing the Category-Date options in Publishing Options, or the Rebuild Site drop-down this should help. Plus, a tweak that may help Rebuild Queue users.

Powered by
Movable Type 3.33