imported>Dawning
m 1 revision imported
the mass documenting
 
Line 1: Line 1:
This module is used by [[Template:Navbox]].
'''Module:Navbox is the "RANGER" navigation-box engine that turns a {{tl|Navbox}} template's title/header/group/list parameters into a collapsible, styled navigation box at the bottom of a page.'''
__TOC__
 
== 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 (<code>header</code>), groups (<code>group</code>) and link lists (<code>list</code>) — and renders the nested HTML with the right CSS classes (all prefixed <code>ranger-</code>) and MediaWiki collapsing.
 
It is a flexible, generic engine: parameter names can be written many ways (camelCase, spaced, hyphenated, indexed like <code>group1.2</code> or <code>1.2:group</code>) 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 {{tl|Navbox}} (which is just <code>{{#invoke:Navbox|main}}</code>) and fill in parameters. Many ready-made wrappers exist, e.g. {{tl|Dungeon Navbox}}, {{tl|Biome Navbox}}, and the untiered-item navboxes like {{tl|UTSword Navbox}}.
 
== Functions / entry points ==
 
{| class="wikitable"
! Function (#invoke) !! What it does !! Called by
|-
| <code>p.main</code> || 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 <code>[[Category:Pages with navboxes]]</code>. || {{tl|Navbox}} and its wrappers ({{tl|Dungeon Navbox}}, {{tl|Biome Navbox}}, {{tl|UTSword Navbox}}, etc.)
|-
| <code>p.build</code> || 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 <code>Module:PillNavbox</code>)
|-
| <code>p.mergeArgs</code> || 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 <code>p.main</code> does. || Wrapping modules, and internally by <code>p.main</code>
|}
 
== How it's used ==
 
{{tl|Navbox}} is simply:
 
<pre>
<includeonly>{{#invoke:Navbox|main}}</includeonly>
</pre>
 
A page or wrapper template then supplies parameters, for example:
 
<pre>
{{Navbox
| title  = Dungeons
| state  = collapsed
| header1 = Frozen
|  group1.1 = Tier 1
|  list1.1 = [[Ice Cave]] · [[Frozen Ruins]]
| header2 = Desert
|  list2  = [[Desert Temple]] · [[Anubis Lair]]
}}
</pre>
 
A child navbox embedded inside another uses <code>{{Navbox|child| ... }}</code>.
 
'''Ordinary editors use {{tl|Navbox}} (or a themed wrapper), not <code>#invoke</code> directly.''' To build a new family of navboxes with a different look, a maintainer can write a small module that calls <code>require('Module:Navbox').build(...)</code> with a custom config.
 
== Notes ==
 
* '''Parameter naming is forgiving.''' <code>listStyle</code>, <code>list style</code>, <code>list1_style</code>, <code>1.2:list_style</code> etc. all normalise to the same canonical key. Indices like <code>group1.1</code> build the nesting tree. Aliases are mapped too: <code>class</code>→navbox_class, <code>style</code>/<code>css</code>→navbox_style, <code>collapsible</code>→state, <code>editlink</code>/<code>navbar</code>→meta, <code>name</code>→template, <code>evenodd</code>→striped.
* '''Collapsing.''' <code>|state=</code> accepts <code>collapsed</code>, <code>expanded</code>, or <code>no</code>/<code>off</code>/<code>plain</code> (not collapsible). A <code>header</code> whose value is two or more hyphens (<code>--</code>) starts a new, non-collapsible section without a visible header.
* '''Style/class cascade.''' Style and class parameters merge from general to specific (e.g. <code>subgroup_style</code> → <code>subgroup_level_1_style</code> → <code>group_1.1_style</code>). Prefixing a value with <code>--</code> 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 <code>auto_flatten_top_level</code> in the config) to keep the hierarchy clean.
* '''Edit/meta link.''' The small "view/edit this template" link (the <code>meta</code>/navbar) is on by default; turn off with <code>|meta=no</code> (or its aliases). Hover text comes from the <code>Navbox-edit-hover</code> system message.
* '''Config & hooks.''' Defaults live in the <code>config</code> table at the top of the module, but should be changed via the <code>onLoadConfig</code> hook in <code>Module:Navbox/Hooks</code> (if present) rather than edited inline. Other hooks fire during arg sanitising and tree building.
* All output classes are prefixed <code>ranger-</code> (this engine's name is RANGER), and the wiki's CSS/collapse gadget styles those.
* '''Related:''' {{tl|Navbox}}, {{tl|Dungeon Navbox}}, {{tl|Biome Navbox}}, the UT…Navbox family, and <code>Module:Navbox/Hooks</code>.

Latest revision as of 11:54, 20 June 2026

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_style etc. all normalise to the same canonical key. Indices like group1.1 build 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= accepts collapsed, expanded, or no/off/plain (not collapsible). A header whose 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_stylesubgroup_level_1_stylegroup_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_level in 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 the Navbox-edit-hover system message.
  • Config & hooks. Defaults live in the config table at the top of the module, but should be changed via the onLoadConfig hook in Module: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, and Module:Navbox/Hooks.