From fffe0005ff1f369e3ffac25db41487fb1bec41ec Mon Sep 17 00:00:00 2001 From: albertlast Date: Sun, 9 Aug 2026 16:42:58 +0200 Subject: [PATCH] Gives the two indexes one copy of the board list loop BoardIndex.template.php and MessageIndex.template.php each carried their own copy of the loop that draws a list of boards - the one calling the template_bi_* helpers for the icon, info, stats, last post and children. The two were identical, 32 lines apiece, differing only in the array they walked and in how deeply the emitted HTML was indented. It becomes template_bi_board_list(), living beside the helpers it calls. MessageIndex already loads BoardIndex for those helpers, so there is nothing new to load; #9403 shared the helpers, this shares the loop that calls them. Markup is untouched. The theme branch renames these classes - up_contain to board_container, info to board_info, lastpost to board_lastpost - but that needs its index.css slice to come with it, so this keeps what is there. Board index and the child board list on a board with children both render identically, compared as normalised HTML. Signed-off-by: Mathias Albert Signed-off-by: albertlast --- Themes/default/BoardIndex.template.php | 77 ++++++++++++++---------- Themes/default/MessageIndex.template.php | 33 +--------- 2 files changed, 47 insertions(+), 63 deletions(-) diff --git a/Themes/default/BoardIndex.template.php b/Themes/default/BoardIndex.template.php index 22c218c72e..385875b1d5 100644 --- a/Themes/default/BoardIndex.template.php +++ b/Themes/default/BoardIndex.template.php @@ -82,12 +82,43 @@ function template_boardindex() + '; + } + + echo ' + '; + + // Show the mark all as read button? + if (!User::$me->is_guest && !empty(Utils::$context['categories'])) { + echo ' +
+ ', template_button_strip(Utils::$context['mark_read_button'], 'right'), ' +
'; + } +} + +/** + * Outputs a list of boards, each one drawn by the template_bi_* helpers below. + * + * The board index calls this once per category, and the message index calls it + * for the child boards of the board being viewed. Both used to carry their own + * copy of this loop. + * + * Each board has: new (is it new?), id, name, description, moderators (see + * below), link_moderators (just a list.), children (see below.), link_children + * (easier to use.), children_new (are they new?), topics (# of), posts (# of), + * link, href, and last_post. (see below.) + * + * @param array $boards The boards to draw, in the order they go in. + */ +function template_bi_board_list(array $boards): void +{ + foreach ($boards as $board) { + echo '
', function_exists('template_bi_' . $board['type'] . '_icon') ? call_user_func('template_bi_' . $board['type'] . '_icon', $board) : template_bi_board_icon($board), ' @@ -96,43 +127,27 @@ function template_boardindex() ', function_exists('template_bi_' . $board['type'] . '_info') ? call_user_func('template_bi_' . $board['type'] . '_info', $board) : template_bi_board_info($board), '
'; - // Show some basic information about the number of posts, etc. - echo ' + // Show some basic information about the number of posts, etc. + echo '
', function_exists('template_bi_' . $board['type'] . '_stats') ? call_user_func('template_bi_' . $board['type'] . '_stats', $board) : template_bi_board_stats($board), '
'; - // Show the last post if there is one. - echo' + // Show the last post if there is one. + echo '
', function_exists('template_bi_' . $board['type'] . '_lastpost') ? call_user_func('template_bi_' . $board['type'] . '_lastpost', $board) : template_bi_board_lastpost($board), '
'; - // Won't somebody think of the children! - if (function_exists('template_bi_' . $board['type'] . '_children')) { - call_user_func('template_bi_' . $board['type'] . '_children', $board); - } else { + // Won't somebody think of the children! + if (function_exists('template_bi_' . $board['type'] . '_children')) { + call_user_func('template_bi_' . $board['type'] . '_children', $board); + } else { template_bi_board_children($board); - } - - echo ' -
'; } echo ' - - '; - } - - echo ' - '; - - // Show the mark all as read button? - if (!User::$me->is_guest && !empty(Utils::$context['categories'])) { - echo ' -
- ', template_button_strip(Utils::$context['mark_read_button'], 'right'), ' -
'; + '; } } diff --git a/Themes/default/MessageIndex.template.php b/Themes/default/MessageIndex.template.php index 74c75452b5..4a5c728871 100644 --- a/Themes/default/MessageIndex.template.php +++ b/Themes/default/MessageIndex.template.php @@ -79,38 +79,7 @@ function template_main()

', Lang::getTxt('sub_boards', file: 'General'), '

'; - foreach (Utils::$context['boards'] as $board) { - echo ' -
-
- ', function_exists('template_bi_' . $board['type'] . '_icon') ? call_user_func('template_bi_' . $board['type'] . '_icon', $board) : template_bi_board_icon($board), ' -
-
- ', function_exists('template_bi_' . $board['type'] . '_info') ? call_user_func('template_bi_' . $board['type'] . '_info', $board) : template_bi_board_info($board), ' -
'; - - // Show some basic information about the number of posts, etc. - echo ' -
- ', function_exists('template_bi_' . $board['type'] . '_stats') ? call_user_func('template_bi_' . $board['type'] . '_stats', $board) : template_bi_board_stats($board), ' -
'; - - // Show the last post if there is one. - echo ' -
- ', function_exists('template_bi_' . $board['type'] . '_lastpost') ? call_user_func('template_bi_' . $board['type'] . '_lastpost', $board) : template_bi_board_lastpost($board), ' -
'; - - // Won't somebody think of the children! - if (function_exists('template_bi_' . $board['type'] . '_children')) { - call_user_func('template_bi_' . $board['type'] . '_children', $board); - } else { - template_bi_board_children($board); - } - - echo ' -
'; - } + template_bi_board_list(Utils::$context['boards']); echo ' ';