diff --git a/public/forum/index.php b/public/forum/index.php index ca5e7a39..a840b1cb 100644 --- a/public/forum/index.php +++ b/public/forum/index.php @@ -4,6 +4,7 @@ use Misuzu\Database; require_once __DIR__ . '/../../misuzu.php'; $categories = forum_get_root_categories(); +$blankForum = count($categories) <= 1 && $categories[0]['forum_children'] < 1; foreach ($categories as $key => $category) { $categories[$key]['forum_subforums'] = forum_get_children($category['forum_id'], $app->getUserId()); @@ -20,4 +21,5 @@ foreach ($categories as $key => $category) { echo $app->getTemplating()->render('forum.index', [ 'forum_categories' => $categories, + 'forum_empty' => $blankForum, ]); diff --git a/src/Forum/forum.php b/src/Forum/forum.php index aa811fba..f009623c 100644 --- a/src/Forum/forum.php +++ b/src/Forum/forum.php @@ -51,8 +51,10 @@ function forum_fetch(int $forumId): array WHERE `forum_id` = :forum_id '); $getForum->bindValue('forum_id', $forumId); + $getForum->execute(); + $forums = $getForum->fetch(); - return $getForum->execute() ? $getForum->fetch() : []; + return $forums ? $forums : []; } function forum_get_root_categories(): array diff --git a/src/Forum/topic.php b/src/Forum/topic.php index 23ac680f..c38cdd55 100644 --- a/src/Forum/topic.php +++ b/src/Forum/topic.php @@ -50,8 +50,10 @@ function forum_topic_fetch(int $topicId): array AND t.`topic_deleted` IS NULL '); $getTopic->bindValue('topic_id', $topicId); + $getTopic->execute(); + $topic = $getTopic->fetch(); - return $getTopic->execute() ? $getTopic->fetch() : []; + return $topic ? $topic : []; } function forum_topic_bump(int $topicId): bool diff --git a/views/mio/forum/index.twig b/views/mio/forum/index.twig index d5951586..5c8b9d17 100644 --- a/views/mio/forum/index.twig +++ b/views/mio/forum/index.twig @@ -6,21 +6,30 @@ {% set canonical_url = '/forum/' %} {% block content %} - {% for category in forum_categories %} - {% if category.forum_children > 0 %} - {{ forum_category_listing(category.forum_subforums, category.forum_name) }} - {% endif %} - {% endfor %} + {% if not forum_empty %} + {% for category in forum_categories %} + {% if category.forum_children > 0 %} + {{ forum_category_listing(category.forum_subforums, category.forum_name) }} + {% endif %} + {% endfor %} -
-
Actions
-
- Mark All Read - Unanswered Posts - New Posts - Your Posts + -
+ {% else %} +
+
Forums
+
+

There are no forums yet, check back later!

+
+
+ {% endif %} {{ navigation(mio_navigation, '/forum/') }} {% endblock %}