Building a Weighted Post Date List


Published on January 4, 2005 at 7:02 PM EST
In the Tutorials category.

Really, this is just stretching the work I did to create the previous weighted lists (keywords and categories). This weighted post date list shows when you’ve posted the most to your Movable Type weblog(s), sort of like the BlogTimes plugin—but completely different.

Below is the weighted post date list for this web site:

april august december february friday january july june march may monday november october saturday september sunday thursday tuesday wednesday 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 1976 1987 1989 1990 1991 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005

Put this PHP code into an Index Template to use.

<?php

// Build the list of words and convert everything to lowercase.
$string = strtolower('<MTEntries lastn="10000"><MTEntryDate format="%A %e %B %Y" encode_php="q"> </MTEntries>');

// Remove punctuation.
$wordlist = preg_split('/\s+/i', $string);

// Build an array of the unique words and number of times they occur.
$a = array_count_values( $wordlist );

// Sort the keys alphabetically.
ksort( $a );

// Print the data.
echo '<p class="noindent">';

foreach ($a as $word => $count) {
 if ($count <= 5) { $size = 75;
 } elseif ($count <= 10) { $size = 100;
 } elseif ($count <= 20) { $size = 125;
 } elseif ($count <= 30) { $size = 150;
 } elseif ($count <= 40) { $size = 175;
 } elseif ($count <= 50) { $size = 200;
 } elseif ($count <= 75) { $size = 225;
 } elseif ($count <= 100) { $size = 250;
 } elseif ($count <= 150) { $size = 275;
 } elseif ($count <= 200) { $size = 310;
 } elseif ($count <= 250) { $size = 350;
 }


 echo ' <span style="font-size: ' . $size . '%;"><acronym title="This keyword occurs ' . $count . ' times.">' . $word . '</acronym></span> ';
}

echo '</p>';

?>

Similar to the weighted keyword list, you might want to edit what is captured in $string, change font sizes in $size, or change the “weighting” with $count.