Skip to content

[3.0] Theme split (wave 4, part 9) — share the board index's board helpers with the message index - #9403

Merged
live627 merged 2 commits into
SimpleMachines:release-3.0from
albertlast:3.0/theme-boardindex-shared-helpers
Aug 9, 2026
Merged

[3.0] Theme split (wave 4, part 9) — share the board index's board helpers with the message index#9403
live627 merged 2 commits into
SimpleMachines:release-3.0from
albertlast:3.0/theme-boardindex-shared-helpers

Conversation

@albertlast

Copy link
Copy Markdown
Collaborator

Description

Stacked on #9385. The diff against release-3.0 shown by GitHub includes that PR's commit. Review the top commit, or merge #9385 first.

BoardIndex.template.php and MessageIndex.template.php each defined the same seven functions:

template_bi_board_icon()      template_bi_board_stats()     template_bi_board_lastpost()
template_bi_redirect_icon()   template_bi_redirect_stats()  template_bi_board_children()
template_bi_board_info()

Five of the seven were byte for byte identical. The message index drew its child board rows from a second copy that nothing was keeping in step with the first.

It now loads BoardIndex alongside its own template and uses the one set, dropping 136 lines. That is only possible because #9385 took template_main() out of BoardIndex.template.php — with it still there, loadTemplate('BoardIndex') from the message index would fatal on the redeclaration. Hence the stacking.

The two that had drifted
  • template_bi_board_info() guarded the moderator line differently:

    // MessageIndex
    if (!empty($board['moderators']) || !empty($board['moderator_groups'])) {
    // BoardIndex
    if (!empty($board['link_moderators'])) {

    Both bodies then count() and list $board['link_moderators']. The board index has the guard that matches what the body actually reads, so that is the one that survives. The message index version would have counted and listed an empty array had the two ever disagreed.

  • template_bi_board_children() differed only in the docblock of the next function, which the comparison picked up. No code difference.

Checked

Board index and message index both render byte for byte as before — diffed with a child board present, only the clock and the cron timestamp move:

< <time datetime="2026-08-08T16:43:07Z">Aug 08, 2026, 04:43 PM</time>
> <time datetime="2026-08-08T16:44:04Z">Aug 08, 2026, 04:44 PM</time>
< $.get('…' + "/cron.php?ts=1786207380");
> $.get('…' + "/cron.php?ts=1786207440");

Actions/Unread.php also loads MessageIndex, but its sub-templates live in Recent.template.php and never call these helpers, so it does not need BoardIndex and does not get it.

Part of the #7933 split. Numbering restarts each wave.

Issues References (Fixes|Related|Closes)

Related to #7933

The board index was drawn by a template layer whose two halves each called one
function: template_boardindex_outer_above() called template_newsfader(), and
template_boardindex_outer_below() called template_info_center(). A layer says
that something wraps around the middle of the page, which is not what is
happening here. The news fader, the board list and the info centre are three
things one after another.

Theme::loadSubTemplates() already walks a sub_templates array, so the three can
be named directly and the layer and its two forwarding functions go. The board
list is renamed from template_main() to template_boardindex() to be nameable.

Output is unchanged.

Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
BoardIndex.template.php and MessageIndex.template.php both defined
template_bi_board_icon(), _redirect_icon(), _board_info(), _board_stats(),
_redirect_stats(), _board_lastpost() and _board_children(). Five of the
seven were identical; the message index kept the child board rows drawing
themselves from a second copy that nobody was keeping in step.

The message index now loads BoardIndex as well and uses the one set. That is
only possible now the board index no longer has a template_main() of its own,
which is why this sits on top of that change rather than beside it.

The two that had drifted:

 - template_bi_board_info() guarded the moderator line on
   !empty($board['moderators']) || !empty($board['moderator_groups']) here,
   against !empty($board['link_moderators']) on the board index. Both then
   count() and list link_moderators, so the board index has the guard that
   matches what the body reads, and that is the one that survives.
 - template_bi_board_children() differed only in the docblock of the function
   after it, which the split picked up.

Board index and message index both render byte for byte as before, on a board
with a child board.

Signed-off-by: Mathias Papenbrock <mathiaspapealbert@hotmail.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
@albertlast albertlast mentioned this pull request Aug 8, 2026
@jdarwood007 jdarwood007 added this to the 3.0 Alpha 5 milestone Aug 8, 2026
@live627
live627 merged commit 99b6c82 into SimpleMachines:release-3.0 Aug 9, 2026
4 checks passed
albertlast added a commit to albertlast/SMF2.1 that referenced this pull request Aug 9, 2026
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; SimpleMachines#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 <mathiaspapealbert@hotmail.com>
Signed-off-by: albertlast <mathiaspapealbert@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants