Fix some oversights and add a fallback page for when there are no forums.
This commit is contained in:
parent
8b2e174d40
commit
60d14f9709
4 changed files with 30 additions and 15 deletions
|
@ -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,
|
||||
]);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
{% set canonical_url = '/forum/' %}
|
||||
|
||||
{% block content %}
|
||||
{% if not forum_empty %}
|
||||
{% for category in forum_categories %}
|
||||
{% if category.forum_children > 0 %}
|
||||
{{ forum_category_listing(category.forum_subforums, category.forum_name) }}
|
||||
|
@ -21,6 +22,14 @@
|
|||
<a class="input__button forum__actions__button">Your Posts</a>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="container">
|
||||
<div class="container__title">Forums</div>
|
||||
<div class="container__content">
|
||||
<p>There are no forums yet, check back later!</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{{ navigation(mio_navigation, '/forum/') }}
|
||||
{% endblock %}
|
||||
|
|
Loading…
Add table
Reference in a new issue