The reason the count only comes up as 1 is because the handler for the MTArchiveNext and MTArchivePrevious tags only loads one entry into the context. The handler for MTArchiveCount works by counting the number of entries loaded into the context, or by using the archive_count value if one has been stashed.
Apparently, MTEntries won't work here either; you'd only see one entry.
It seems the only solution for now is to 1) create a plugin to load the entries for a time period, and use that tag within MTArchivePrevious and MTArchiveNext, or 2) hack lib/Template/Context.pm to redefine the handler. The hack would look like this:
CODE
sub _hdlr_archive_prev_next {
my($ctx, $args, $cond) = @_;
my $tag = $ctx->stash('tag');
my $is_prev = $tag eq 'ArchivePrevious';
my $ts = $ctx->{current_timestamp}
or return $ctx->error(MT->translate(
"You used an [_1] without a date context set up.", "<MT$tag>" ));
my $at = $_[1]->{archive_type} || $ctx->{current_archive_type};
return $ctx->error(MT->translate(
"[_1] can be used only with Daily, Weekly, or Monthly archives.",
"<MT$tag>" ))
unless $at eq 'Daily' || $at eq 'Weekly' || $at eq 'Monthly';
my $res = '';
my @arg = ($ts, $ctx->stash('blog_id'), $at);
push @arg, $is_prev ? 'previous' : 'next';
my $helper = $TypeHandlers{$at}{helper};
if (my $entry = get_entry(@arg)) {
my $builder = $ctx->stash('builder');
# Comment out this line
# local $ctx->{__stash}->{entries} = [ $entry ];
my($start, $end) = $helper->($entry->created_on);
local $ctx->{current_timestamp} = $start;
local $ctx->{current_timestamp_end} = $end;
# Add this section
local $ctx->{__stash}->{entries};
if($args->{all_entries}) {
my @entries = MT::Entry->load({blog_id => $ctx->stash('blog_id'),
created_on => [$start, $end],
status => MT::Entry::RELEASE()},
{range => {created_on => 1}});
$ctx->{__stash}->{entries} = \@entries;
}
else {
$ctx->{__stash}->{entries} = [ $entry ];
}
# End section
defined(my $out = $builder->build($ctx, $ctx->stash('tokens'),
$cond))
or return $ctx->error( $builder->errstr );
$res .= $out;
}
$res;
}
I caution that's untested but it should work.
I'd guess the reason MT doesn't load all the entries by default is that there's no reason to do so for most purposes. This hack adds an all_entries argument to the MTArchivePrevious and MTArchiveNext tags, so if you put all_entries="1" in there it should load the entries successfully. Then MTArchiveCount should work, as should MTEntries.
Since a hack is a bit of an ugly solution anyway though, I'd still suggest using a plugin. If no such plugin exists, I'll gladly step up.
Lummox JR