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';
|
require_once __DIR__ . '/../../misuzu.php';
|
||||||
|
|
||||||
$categories = forum_get_root_categories();
|
$categories = forum_get_root_categories();
|
||||||
|
$blankForum = count($categories) <= 1 && $categories[0]['forum_children'] < 1;
|
||||||
|
|
||||||
foreach ($categories as $key => $category) {
|
foreach ($categories as $key => $category) {
|
||||||
$categories[$key]['forum_subforums'] = forum_get_children($category['forum_id'], $app->getUserId());
|
$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', [
|
echo $app->getTemplating()->render('forum.index', [
|
||||||
'forum_categories' => $categories,
|
'forum_categories' => $categories,
|
||||||
|
'forum_empty' => $blankForum,
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -51,8 +51,10 @@ function forum_fetch(int $forumId): array
|
||||||
WHERE `forum_id` = :forum_id
|
WHERE `forum_id` = :forum_id
|
||||||
');
|
');
|
||||||
$getForum->bindValue('forum_id', $forumId);
|
$getForum->bindValue('forum_id', $forumId);
|
||||||
|
$getForum->execute();
|
||||||
|
$forums = $getForum->fetch();
|
||||||
|
|
||||||
return $getForum->execute() ? $getForum->fetch() : [];
|
return $forums ? $forums : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function forum_get_root_categories(): array
|
function forum_get_root_categories(): array
|
||||||
|
|
|
@ -50,8 +50,10 @@ function forum_topic_fetch(int $topicId): array
|
||||||
AND t.`topic_deleted` IS NULL
|
AND t.`topic_deleted` IS NULL
|
||||||
');
|
');
|
||||||
$getTopic->bindValue('topic_id', $topicId);
|
$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
|
function forum_topic_bump(int $topicId): bool
|
||||||
|
|
|
@ -6,21 +6,30 @@
|
||||||
{% set canonical_url = '/forum/' %}
|
{% set canonical_url = '/forum/' %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% for category in forum_categories %}
|
{% if not forum_empty %}
|
||||||
{% if category.forum_children > 0 %}
|
{% for category in forum_categories %}
|
||||||
{{ forum_category_listing(category.forum_subforums, category.forum_name) }}
|
{% if category.forum_children > 0 %}
|
||||||
{% endif %}
|
{{ forum_category_listing(category.forum_subforums, category.forum_name) }}
|
||||||
{% endfor %}
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
<div class="container forum__actions">
|
<div class="container forum__actions">
|
||||||
<div class="container__title">Actions</div>
|
<div class="container__title">Actions</div>
|
||||||
<div class="container__content forum__actions__content">
|
<div class="container__content forum__actions__content">
|
||||||
<a class="input__button forum__actions__button">Mark All Read</a>
|
<a class="input__button forum__actions__button">Mark All Read</a>
|
||||||
<a class="input__button forum__actions__button">Unanswered Posts</a>
|
<a class="input__button forum__actions__button">Unanswered Posts</a>
|
||||||
<a class="input__button forum__actions__button">New Posts</a>
|
<a class="input__button forum__actions__button">New Posts</a>
|
||||||
<a class="input__button forum__actions__button">Your Posts</a>
|
<a class="input__button forum__actions__button">Your Posts</a>
|
||||||
|
</div>
|
||||||
</div>
|
</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/') }}
|
{{ navigation(mio_navigation, '/forum/') }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Add table
Reference in a new issue