I wanted to have a very simple archive page for my blog, but I didn't want to install any extra modules. So I just wrote this code:
<?php
$sql = "select n.title, n.nid, n.created, n.*
from node n
where n.type = 'story'
and n.status = 1
order by n.created desc";
$result = db_query($sql);
$output = '';
$anode = db_fetch_object($result);
while ($anode) {
$current_month = date('F', $anode->created);
$output .= "$current_month " . date('Y', $anode->created) . "
\n";
$output .= "\n";
do {
$output .= "- " .
date('d', $anode->created) . " " .
l($anode->title, "node/$anode->nid") . "
";
} while (($anode = db_fetch_object($result)) &&
(date('F', $anode->created) == $current_month));
$output .= "
\n";
}
print $output;
?>
You can see the result here.
Submitted by Eneko Alonso on Thu, 2008-05-08 20:57
Post new comment