summaryrefslogtreecommitdiff
path: root/category.php
diff options
context:
space:
mode:
authorcflip <36554078+cflip@users.noreply.github.com>2021-03-24 18:29:41 -0600
committercflip <36554078+cflip@users.noreply.github.com>2021-03-24 18:29:41 -0600
commitc9732788143886b611cb2fecfb53daf3d8add48f (patch)
tree8dd3152611bf59cc4982be9839e340ec89d0bee2 /category.php
parent9c619586639b9ac0f107e63a54b5522d75ea2ee2 (diff)
Show latest thread/post on pages
Diffstat (limited to 'category.php')
-rw-r--r--category.php22
1 files changed, 20 insertions, 2 deletions
diff --git a/category.php b/category.php
index a71029e..ad4faa6 100644
--- a/category.php
+++ b/category.php
@@ -28,13 +28,31 @@ if (!isset($_GET['id']) || !filter_var($_GET['id'], FILTER_VALIDATE_INT)) {
<th>Latest Post</th>
</tr>
<?php
+ function cmp($a, $b) {
+ $da = strtotime($a->date_lastpost);
+ $db = strtotime($b->date_lastpost);
+
+ if ($da == $db) return 0;
+
+ return ($da > $db) ? -1 : 1;
+ }
+
$threads = $current->get_threads($dbc);
+ usort($threads, "cmp");
foreach ($threads as $thread) {
+ $latest_post = $thread->get_latest_post($dbc);
+
echo '<tr>';
echo '<td><b><a href="../thread/' . $thread->id . '">' . $thread->subject . '</a></b><br>';
- echo '<small>by ' . $thread->author->name . ' on ' . date('M d, Y', strtotime($thread->date_created)) . '</small></td>';
- echo '<td>' . date('M d, Y', strtotime($thread->date_lastpost)) . '</td>';
+ echo '<small>by <b><a href="../user/' . $thread->author->name . '">' . $thread->author->name . '</a></b> on ' . date('M d, Y', strtotime($thread->date_created)) . '</small></td>';
+
+ if (!is_null($latest_post)) {
+ echo '<td>by <b><a href="../user/' . $latest_post->author->name . '">' . $latest_post->author->name . '</a></b><br><small>on ' . $latest_post->date . '</small></td>';
+ } else {
+ echo '<td>No posts yet!</td>';
+ }
+
echo '</tr>';
}
?>