This is the documentation page for Module:Navbox
Module:Navbox is the "RANGER" navigation-box engine that turns a {{Navbox}} template's title/header/group/list parameters into a collapsible, styled navigation box at the bottom of a page.
Overview
Navboxes are the collapsible link tables you see at the foot of related pages (e.g. the Dungeon Navbox, Biome Navbox, or the per-weapon "UT … Navbox" templates). This module reads the navbox's parameters — a title, optional above/below text, and a hierarchy of sections (header), groups (group) and link lists (list) — and renders the nested HTML with the right CSS classes (all prefixed ranger-) and MediaWiki collapsing.
It is a flexible, generic engine: parameter names can be written many ways (camelCase, spaced, hyphenated, indexed like group1.2 or 1.2:group) and are all normalised to a canonical form. Sections can be nested to arbitrary depth, and style/class parameters cascade from general to specific.
Editors do not call the module directly — they use {{Navbox}} (which is just
) and fill in parameters. Many ready-made wrappers exist, e.g. {{Dungeon Navbox}}, {{Biome Navbox}}, and the untiered-item navboxes like {{UTSword Navbox}}.
Functions / entry points
| Function (#invoke) | What it does | Called by |
|---|---|---|
p.main |
The template entry point. Merges the invoke args with the parent template args (parent wins), parses/normalises them, builds the section tree, and renders the navbox. Adds . |
{{Navbox}} and its wrappers ({{Dungeon Navbox}}, {{Biome Navbox}}, {{UTSword Navbox}}, etc.)
|
p.build |
The entry point for other Lua modules that want to wrap the navbox. Takes an args table and renders it; can optionally re-parse args, merge a custom config, or override hooks. Used to build derived navbox styles (e.g. a "pill" navbox). | Other modules (e.g. a custom Module:PillNavbox)
|
p.mergeArgs |
Helper that merges a frame's own args with its parent's args (parent overrides), trimming blanks. Provided so a wrapping module can collect args the same way p.main does. |
Wrapping modules, and internally by p.main
|
How it's used
{{Navbox}} is simply:
<includeonly>{{#invoke:Navbox|main}}</includeonly>
A page or wrapper template then supplies parameters, for example:
{{Navbox
| title = Dungeons
| state = collapsed
| header1 = Frozen
| group1.1 = Tier 1
| list1.1 = [[Ice Cave]] · [[Frozen Ruins]]
| header2 = Desert
| list2 = [[Desert Temple]] · [[Anubis Lair]]
}}
A child navbox embedded inside another uses !!C$H$I$L$D!!null.
Ordinary editors use {{Navbox}} (or a themed wrapper), not #invoke directly. To build a new family of navboxes with a different look, a maintainer can write a small module that calls require('Module:Navbox').build(...) with a custom config.
Notes
- Parameter naming is forgiving.
listStyle,list style,list1_style,1.2:list_styleetc. all normalise to the same canonical key. Indices likegroup1.1build the nesting tree. Aliases are mapped too:class→navbox_class,style/css→navbox_style,collapsible→state,editlink/navbar→meta,name→template,evenodd→striped. - Collapsing.
|state=acceptscollapsed,expanded, orno/off/plain(not collapsible). Aheaderwhose value is two or more hyphens (--) starts a new, non-collapsible section without a visible header. - Style/class cascade. Style and class parameters merge from general to specific (e.g.
subgroup_style→subgroup_level_1_style→group_1.1_style). Prefixing a value with--stops the cascade and uses only that value. - Auto-flatten. If a section contains a single sub-list with no group/content of its own, its sublists are promoted to the parent level (controlled by
auto_flatten_top_levelin the config) to keep the hierarchy clean. - Edit/meta link. The small "view/edit this template" link (the
meta/navbar) is on by default; turn off with|meta=no(or its aliases). Hover text comes from theNavbox-edit-hoversystem message. - Config & hooks. Defaults live in the
configtable at the top of the module, but should be changed via theonLoadConfighook inModule:Navbox/Hooks(if present) rather than edited inline. Other hooks fire during arg sanitising and tree building. - All output classes are prefixed
ranger-(this engine's name is RANGER), and the wiki's CSS/collapse gadget styles those. - Related:
{{Navbox}},{{Dungeon Navbox}},{{Biome Navbox}}, the UT…Navbox family, andModule:Navbox/Hooks.