Sort by modified time

Also, show last modified time as well as created time.
This commit is contained in:
Robert Miles 2019-10-08 12:17:28 -04:00
parent 1e4ebeddd4
commit 47b7be48fc
1 changed files with 5 additions and 2 deletions

View File

@ -4,7 +4,7 @@
// Otherwise, force pinned post to the top.
function pinned_sort($thread_a,$thread_b) {
if ($thread_a["pinned"] == $thread_b["pinned"]) {
return (($thread_a["created"]>$thread_b["created"])? -1 : 1);
return (($thread_a["last_mod"]>$thread_b["last_mod"])? -1 : 1);
}
if ($thread_a["pinned"]) {
return -1;
@ -20,12 +20,15 @@
$time = round($thread['created']);
$time = new DateTime("@{$time}");
$time = date_format($time, "Y/m/d H:i");
$mod = round($thread['last_mod']);
$mod = new DateTime("@{$mod}");
$mod = date_format($time, "Y/m/d H:i");
$tt = $thread["title"];
$plural = $thread['reply_count']==1 ? "y" : "ies";
$tid = $thread["thread_id"];
echo "\t\t<div class='well'>".PHP_EOL;
echo "\t\t\t<p><a href='?thread_id={$tid}'>{$tt}</a> by {$username} @ {$time}</p>".PHP_EOL;
echo "\t\t\t<p>{$thread['reply_count']} repl{$plural}, last post by {$last_author}";
echo "\t\t\t<p>{$thread['reply_count']} repl{$plural}, last post by {$last_author} @ {$mod}</p>";
echo "\t\t</div>".PHP_EOL;
}
?>