Help - Search - Members - Calendar
Full Version: Count of Posts per day
Movable Type Community Forum > Additional Resources > Tips and Tricks
cjserio
Hello

can someone tell me how i can obtain a count of the number of posts that occured on the day a particular entry being viewed was?

Basically i want the bottom of each post to say "N Posts were made today" so that even if i go into an archive, the bottom of each post will have a count for that particular day.

Thanks
Chris
kadyellebee
I didn't test this out, but if you have Daily archives turned on, this might work.
CODE
<MTArchiveList archive_type="Daily" lastn="1"><$MTArchiveCount$></MTArchiveList> posts made today


If not, post back!

Kristine
cjserio
That definitly looks like it should work but it only works today. None of the old posts show any number >1 even though there are multiple posts that day. I've tried rebuilding the whole site several times.
playfulkitten
This is exactly what I'm looking for, but for a different reason. When someone mouses over a link to a day in the calendar, I'd like it to say how many posts happened that day. However, I don't do daily archiving (though it seems I saw a plugin or hack -- don't remember which -- that allows the MTArchive tag, or replaces the tag, to specify an archive type that isn't turned on). Also, I'd ideally like this to work for all monthly calendars.

I have a template that writes a calendar table for each month of archives available, and use PHP on the main archive page to pull these all together in one page, and I'd like to have the template that creates those tables to also be able to do this. The template that creates my current calendar is an Index template, and the one that creats 'em all is a Monthly template.

Edit: The plugin that lets you do archive types you don't keep files for is ArchiveAnyway
playfulkitten
I'm not finished yet, but I think I found a PHP-based solution, which is fine since I already use that.

Within the MTCalendar tags, I would modify the code to look something like this:

CODE
   <td align="center" class="calendar">
     <span class="calendar<MTCalendarIfToday>today</MTCalendarIfToday>">
<MTCalendarIfEntries>

<?php
 $dailyCt = 0;
<MTEntries>
 $dailyCt++;
</MTEntries>
?>

<MTEntries lastn="1">
   <a href="<$MTEntryLink$>#<$MTCalendarDate format="%d"$>" title="<?php echo $dailyCt;?>"><$MTCalendarDay$></a>
</MTEntries>
</MTCalendarIfEntries>
<MTCalendarIfNoEntries><;$MTCalendarDay$></MTCalendarIfNoEntries>
<MTCalendarIfBlank> </MTCalendarIfBlank>
   </span></td>


Basically, use PHP to count the entries for that day, then later use that count in the link title. (It can't be combined with the second MTEntries tag because it uses lastn="1" to generate just one link; for more than one entry per day there would be multiple links generated. However, the PHP code to count entries would always be 1 if it were placed inside that MTEntries tag.)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.