UPDATE 3.29.04
Lynda has a updated version of this script. I'll leave the content of the post up – but go to her site for the most recent version of the script.
——————————————-
I went looking to see if there was a way to list the most commented on entries within Moveable Type. I know this is a standard Greymatter feature, but I couldn't figure anything out for Moveable Type. Granted, I may not have looked hard enough.
Here is a simple PHP solution. I'm just going to copy and paste the code, it's quite easily customizable if you know what's going on. When I get back I might detail this post a little more.
If you know of a way to do this automatically within Moveable Type, please let me know.
First you will want to create a new index template. Give it any name you'd like, but remember this name for later on. For demonstration purposes, we will pretend the file is named comments.inc.
Copy and paste the following code into the template body:
<?php
<MTEntries lastn="99999">$comments[<$MTEntryID$>] = <$MTEntryCommentCount$>;
</MTEntries>
<MTEntries lastn="99999">$entryinfo[<$MTEntryID$>] = "<$MTEntryTitle encode_html="1" encode_php="qq"$>|<$MTEntryLink$>|<$MTEntryDate format="%m.%d"$>";
</MTEntries>
?>
You can change the MTEntryDate format to however you wish it to display. Save it and rebuild the index files.
Then, open a text editor and paste the following into that, changing only the first two lines per your preference:
<?php
# This is the path to the comments.inc:
include("/home/user/public_html/blog/comments.inc");
# This is the number of results you want to show:
$results = 5;
array_multisort($comments, SORT_DESC, $entryinfo);
$i = 0;
do {
$entries = explode("|", $entryinfo[$i]);
$entry_title = $entries[0];
$entry_link = $entries[1];
$entry_date = $entries[2];
echo "<b>$comments[$i] comments</b>: <a href=\"$entry_link\">$entry_title</a> ($entry_date)<br/>";
$i++;
} while ($i<$results);
?>
Save this file under any name you wish, with a PHP extension. Example, comments.php.
You should now be able to include this file where you'd like on your blog using the following code:
<?php include("/home/user/public_html/blog/comments.php"); ?>
Make sure to change the path to correctly reflect the path to your comments.php