From c9732788143886b611cb2fecfb53daf3d8add48f Mon Sep 17 00:00:00 2001 From: cflip <36554078+cflip@users.noreply.github.com> Date: Wed, 24 Mar 2021 18:29:41 -0600 Subject: Show latest thread/post on pages --- category.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'category.php') 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)) { Latest Post 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 ''; echo '' . $thread->subject . '
'; - echo 'by ' . $thread->author->name . ' on ' . date('M d, Y', strtotime($thread->date_created)) . ''; - echo '' . date('M d, Y', strtotime($thread->date_lastpost)) . ''; + echo 'by ' . $thread->author->name . ' on ' . date('M d, Y', strtotime($thread->date_created)) . ''; + + if (!is_null($latest_post)) { + echo 'by ' . $latest_post->author->name . '
on ' . $latest_post->date . ''; + } else { + echo 'No posts yet!'; + } + echo ''; } ?> -- cgit v1.2.3