this is a more efficient version of archive_calendar_listing that is mysql-specific. it also displays the total post count for each month:
function archive_calendar_listing_mysql() {
$cache = cache_get("archive:calendar:listing");
if (!empty($cache)) {
return $cache->data;
}
$months = array(1 => t("January"), 2 => t("February"), 3 => t("March"), 4 => t
("April"), 5 => t("May"), 6 => t("June"), 7 => t("July"), 8 => t("August"), 9 =>
t("September"), 10 => t("October"), 11 => t("November"), 12 => t("December"));
$sql = "
SELECT SUBSTRING(FROM_UNIXTIME(created), 1, 7) as date, COUNT(*) as count
FROM {node}
WHERE status = 1
GROUP BY date DESC
";
$count = variable_get("archive_months", 0);
if ($count) {
$sql .= " LIMIT $count";
}
$result = db_query($sql);
while ($month = db_fetch_object($result)) {
list($y, $m) = explode('-', $month->date);
$mname = $months[intval($m)];
$items[] = l("$mname $y", "archive/$y/$m") . " (" . $month->count . ")";
}
$output = theme("item_list", $items);
cache_set("archive:calendar:listing", $output);
return $output;
}