diff --git a/public/forum/forum.php b/public/forum/forum.php index acc2de47..8b89493c 100644 --- a/public/forum/forum.php +++ b/public/forum/forum.php @@ -32,19 +32,26 @@ if ($forum['forum_type'] == MSZ_FORUM_TYPE_LINK) { return; } -$topics = forum_may_have_topics($forum['forum_type']) +$forumMayHaveTopics = forum_may_have_topics($forum['forum_type']); +$topics = $forumMayHaveTopics ? forum_topic_listing($forum['forum_id'], user_session_current('user_id', 0), $topicsOffset, $topicsRange) : []; -$forum['forum_subforums'] = forum_get_children($forum['forum_id'], user_session_current('user_id', 0)); +$forumMayHaveChildren = forum_may_have_children($forum['forum_type']); -foreach ($forum['forum_subforums'] as $skey => $subforum) { - $forum['forum_subforums'][$skey]['forum_subforums'] - = forum_get_children($subforum['forum_id'], user_session_current('user_id', 0), true); +if ($forumMayHaveChildren) { + $forum['forum_subforums'] = forum_get_children($forum['forum_id'], user_session_current('user_id', 0)); + + foreach ($forum['forum_subforums'] as $skey => $subforum) { + $forum['forum_subforums'][$skey]['forum_subforums'] + = forum_get_children($subforum['forum_id'], user_session_current('user_id', 0), true); + } } echo tpl_render('forum.forum', [ 'forum_breadcrumbs' => forum_get_breadcrumbs($forum['forum_id']), + 'forum_may_have_topics' => $forumMayHaveTopics, + 'forum_may_have_children' => $forumMayHaveChildren, 'forum_info' => $forum, 'forum_topics' => $topics, 'forum_offset' => $topicsOffset, diff --git a/templates/forum/forum.twig b/templates/forum/forum.twig index f4caa1e3..26c35f17 100644 --- a/templates/forum/forum.twig +++ b/templates/forum/forum.twig @@ -12,11 +12,11 @@