Overview
MostActiveEntries is a Movable Type plugin that will create a container tag of entries that have been the most active (in terms of Trackbacks and comments) in a given period of time. Both the period of time and the number of entries referenced are configurable. By default, it will look for the 7 most active entries from the last week. Common usage would be:
<h1>Most Active Recent Entries</h1>
<ul>
<MTMostActiveEntries>
<li><a href="<$MTEntryPermalink$>" title="<$MTEntryTitle$>"><$MTEntryTitle$></a>
on <a href="<$MTBlogURL$>" title="<$MTBlogName$>"><$MTBlogName$></a><br />
<$MTEntryCommentCount$> comment(s) and <$MTEntryTrackbackCount$> trackback(s)</li>
</MTMostActiveEntries>
</ul>
The source code for v0.1 is available at http://alpha-geek.com/mostactiveentries/mostActiveEntries-0.1.txt. The latest source code will always be available at http://alpha-geek.com/mostactiveentries/mostActiveEntries.txt.
Installation
Download the source code and place the mostActiveEntries.pl file in your installation of Movable Type's plugins directory.
Use
By default, MostActiveEntries will contain the 7 most active entries of the last week. This can be configured using the days or lastn attributes. Setting the days attribute can shorten or extend how far back the plugin will go to gather the entries. So, for example, if you set days to "3", it will display the 7 most active entries (assuming that there are, indeed, 7 entries posted in the last 3 days) in the last 3 days. Similarly, you can set days to "28" to get the 7 most active entries in the last 4 weeks.
Additionally, you can set the lastn attribute to configure the number of entries to gather. By default, MostActiveEntries gathers 7 entries; but that can be extended or shortened.
You can use both tags together to get, for example, the 19 most active entries in the past 37 days:
<MTMostActiveEntries lastn="19" days="37">
.
.
.
</MTMostActiveEntries>
Copyright and License
This source code is copyright Jeremy Smith (jeremy.smith@gmail.com), 2005. And, is released under the MIT License, which basically says, "do whatever you want with this code just don't come crying to me if it is broken or breaks something."
Comments
Nice plugin :)
Can you also set the days variable to effectively be 'open' so that it will display the lastn most active entries in the entire life of the entire weblog (without having to adjust the days value ever once it's set to open)?
..altho I guess just set the days variable to 99999 and that would solve it? (haven't installed it yet)
I receive an error saying that i'm using 'MTEntryLink' tag outside of the context of an entry.
The code is the same as in your example and i'm placing it in weblog's sidebar.
How can i solve it?
hey jeremy and yakoff.ru, I'm getting the same problem.
Yakoff and Martine:
When saving the code, make sure that the text remains unchanged. For some reason, if you are using 'vi' or 'vim', when I go to save the code; it ends up "automatically" commenting out the entire thing.
demonsurfer:
Yes, setting the 'days' attribute to be an arbitrarily high number should effectively do what you want.
I could change the default value for 'days' to mean "at any point in time." That may be what I'll do.
I wish there were some way to come to a consensus with how people would want to use it.
I found where the problem was - you need to comment out line "use warnings" in the start of the file, then it starts working.
(I'm not a perl guru - just guessed when comparing your source with source of another plugin. Actually I don't even know WHY it started working and HOW it works :))
This solution is good for MT 3.14 and 3.15; don't know about other versions.
"I wish there were some way to come to a consensus with how people would want to use it."
Seems good to me, I just wanted to clarify that setting. Perhaps put an option there that a setting of days="0" would mean the entire life of the weblog, or alternatively make the entire life of the blog the default setting, and if users want to limit it to only cover the last X amount of days, they can then add in the days="X" attribute to the tag.
:)
Nice Plugin - is there any way to narrow the results down to one blog? I have three blogs on my installation, but I'd only want it to report on one of the blogs...
I would like to know how to narrow the results down to one blog, too.
Yes, a fix for that would be awesome, I have a photoblog and a regular blog... and it doens't make sense to display the most recently commented entries for my blog - inside my photoblog.
Thanks!
It's not as effective as if it was coded into the perl, but you can use PHP to do a quick hack to only show the active entries from one blog. Here's my code. The only thing you need to change is the extension of the files displaying this code to .php.
It's not a great fix, but it works:
<h1>Most Active Entries</h1>
<?php $MyBlogID = "<$MTBlogID$>"; ?>
<ul>
<MTMostActiveEntries lastn="10" days="365">
<?php
if(<$MTBlogID$> == $MyBlogID){?>
<li><a href="<$MTEntryPermalink$>" title="<$MTEntryTitle$>"><$MTEntryTitle$></a><br />
<$MTEntryCommentCount$> comment(s)</li>
<?php } ?>
</MTMostActiveEntries>
</ul>
Am I the only one getting 500 errors when trying to download the thing? How about you zip the script up so the server doesn't try to execute it?
In 3.2, setting the Days to any value kills it so that it wont produce any results, even if the number of days is high. Has anyone come up with a workaround?