Template:Category/Forum

From Miniscope
Jump to: navigation, search

Render template for Category:Forum pages.

Called by the SemanticSchemas dispatcher when a page belongs to Category:Forum. The page is a forum landing page in a subject namespace (e.g. Forum:Hardware); post pages (DT-styled discussion threads) live as subpages of the talk-namespace counterpart (Forum talk:Hardware/<UTC>_<user>), where the DiscussionForum extension styles them as forum cards and adds the breadcrumb back to the landing. See the DiscussionForum extension's README for the underlying wiring (DT widget, Echo, custom SMW properties, namespace setup).

Two render modes, switched by the Is hub Boolean:

Leaf mode (Is hub unset / No — default)

Renders, top to bottom, inside a .discussionforum-landing wrapper:

  • Parent-forum breadcrumb — small italic kicker "← Back to <Parent>"
 above the description, when Has parent forum is set
  • Optional description as an italic kicker (when Has description is
 set), styled with Codex tokens for light/dark parity
  • Stats meta row — a posts count chip and a "last activity" chip
 rendered when the forum has at least one post; chip styling
 matches Template:Category/Dashboard's meta row
  • Sub-forums KPI-card grid (only when at least one Category:Forum
 page has Has parent forum::<this page>) — natural support for the
 "middle ground" leaf-with-children case (a forum that hosts its
 own posts AND is a parent to sub-forums)
  • Right-justified "Make new post" button (rendered as a
 .wiki-button with the data-discussionforum-new-post
 hook so DiscussionForum's click handler still binds), placed just
 above the posts list à la Discourse's "+ New Topic" placement.
  • Posts list — a styled card-row list (see
 Template:Category/Forum/post_row) surfacing every post subpage
 under the talk-namespace counterpart, sorted by last activity. Top
 posts marked true are pinned
 at the top of the same list (limit 5) with a 📌 marker and warm
 tint; the regular section below shows non-announcements only (the
 post_row template suppresses announcements when called in
 regular mode, so they appear exactly once). A 2px separator,
 drawn by CSS adjacent-sibling, divides pinned from regular only
 when both exist. Each row also carries a color-coded sub-forum
 chip (first-letter hash → 8-color palette); on a pure leaf the
 chip is redundant (one forum) but stays consistent for the
 middle-ground case and for hub-mode listings.

Hub mode (Is hub=Yes)

For pure-navigation pages like Forum:Home that organize the forum tree without hosting their own posts:

  • Breadcrumb + description (same as leaf mode)
  • Sub-forums KPI-card grid (always; if empty, the hub renders just
 the description — that's a misconfiguration to flag)
  • Recent posts list — pinned announcements (across all child
 forums) at the top, then a regular activity feed below. Driven
 by the 
 chained property: each post page has a Has forum
 annotation (set by DiscussionForum's hook from the page's base
 title), and we walk that to its parent forum. The
 sub-forum chip is meaningful here — each row may come from a
 different child forum and the color signals which one.
  • No stats meta row, no "Make new post" button — hubs don't host
 posts directly. Posts created at Forum talk:Home/<slug>
 via URL-crafting will exist but never surface here, by design.

Posts list construction

A single "Posts" / "Recent posts" h2 covers both pinned and regular, matching the user-facing model of "one list of posts with the important ones pinned at the top". Mechanically it's two #ask calls back-to-back:

  1. Pinned — filters true,
 limit=5. Wrapped in
 <div class="wiki-forum-list wiki-forum-list-pinned">
 via intro=/outro=, which SMW omits when
 the query returns zero rows — so there's no empty pinned div when
 no announcements exist.
  1. Regular — no announcement filter, limit=25. The
 post_row template emits empty output for announcement rows (its
 mode=regular default suppresses them), so the visible
 count drops below 25 by however many announcements are in the
 fetch window. Over-fetching by 5 covers the typical case where
 all pinned items also appear in the first 25 by date.

Sorting the regular list separately rather than projecting an "Is announcement desc" sort on a single query keeps the announcement ceiling at 5 — without that cap, a forum with 20 announcements would push 20 pinned rows to the top of one merged list. Also dodges the SMW "!true doesn't match unset values" pitfall: posts that pre-date the Is announcement property (or simply have it unset) wouldn't appear in a negative-filter query, but they show up fine in the unfiltered regular query and don't get suppressed by post_row.

Namespace genericity

Talk namespace and page-name LIKE pattern (used in leaf mode) are derived from Template talk/Category/Forum, so the template works for any subject/talk namespace pair (Forum/ Forum talk, Forum admin/Forum admin talk, Project/Project talk, etc.) — same namespace-agnostic shape as the DiscussionForum extension's hooks. Splitting into a namespace condition Template talk:+ plus a name pattern ~*Category/Forum/* is the working idiom; SMW's ~LIKE doesn't match a namespace prefix as a single token (per DiscussionForum's README).

Hub mode caveats

  • Activity feed is one chain-step deep — posts in grandchild forums
 don't surface. For two-level "Home → leaf" hierarchies (the typical
 miniscope-org / aharoni-lab shape), this is correct. Deeper nesting
 would need a denormalized "Has root forum" annotation in
 DiscussionForum.
  • Activity feed depends on DiscussionForum exposing Has forum
 via its ParserAfterParse hook. Until that lands and a
 rebuildData.php backfill runs, the hub-mode feed will
 show its default= empty-state text.

Parameters (from dispatcher):

  • has_description — the forum's description text
  • has_parent_forum — page name of the parent forum, when nested
  • is_hub — Boolean (Yes/No). When Yes (or any truthy token:
 yes, y, true, t,
 1), renders in hub mode. Empty/missing defaults to leaf
 mode — the typical "open forum" stays open with no field set.