Last July, as in July ’03, I posted about some modifications I made to MoveableType. One thing I had done was a plugin for SETI stats, the other was an actual code modifcation for a “recently archived” sidebar item instead of recently posted. Well, somewhere along the way I seem to have lost that code modification as I noticed my “recently archived” item wasn’t working right. And wouldn’t you know it, I seemed to have made a really boneheaded mistake of not saving the code anywhere! To make a long story short, I figured out, once again, how to do it. It’s my goal to make sure I don’t ever have to spend another couple hours figuring this one out, so I’m gonna post the patch here. As an added bonus, that means other people can use it, too :).
--- Context.pm.orig 2004-12-14 23:11:57.000000000 -0500
+++ Context.pm 2004-12-15 01:15:09.000000000 -0500
@@ -626,6 +626,19 @@
$args{direction} = 'descend';
$args{limit} = $last;
$args{offset} = $args->{offset} if $args->{offset};
+ } elsif (my $days_offset = $args->{days_offset}) {
+ my $sec = 3600 * 24; # Seconds in a day
+ my $days = $args->{days};
+ my @ago = offset_time_list(time - $sec * $days_offset,
+ $ctx->stash('blog_id'));
+ my $ago_s = sprintf "%04d%02d%02d%02d%02d%02d",
+ $ago[5]+1900, $ago[4]+1, @ago[3,2,1,0];
+ @ago = offset_time_list(time - $sec * $days_offset - $sec * $days,
+ $ctx->stash('blog_id'));
+ my $ago_e = sprintf "%04d%02d%02d%02d%02d%02d",
+ $ago[5]+1900, $ago[4]+1, @ago[3,2,1,0];
+ $terms{created_on} = [ $ago_e, $ago_s ];
+ %args = ( range => { created_on => 1 } );
} elsif (my $days = $args->{days}) {
my @ago = offset_time_list(time - 3600 * 24 * $days,
$ctx->stash('blog_id'));
Mostly it’s a duplicate of the block for $args->{days}
, but with some modifications to make it do a starting and ending date. The template block to get this in my sidebar is (I may tweak these number is the future, but it’s just a config option):
<div class="sidetitle">
Recently Archived
</div>
<div class="side">
<MTEntries days="60" days_offset="21">
<a xhref="<$MTEntryPermalink$>" mce_href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><br />
</MTEntries>
</div>
This will put any entry from 21-81 old days under the “recently archived” heading. This is, of course, a modification to the version of MoveableType that I’m running, which is version 2.64. If you’re running a different version, your results may very.