Template:Navbox

From Sword of Moonlight Wiki
Revision as of 18:53, 12 September 2024 by Verdite cat (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Template documentation follows
Note: the template above may sometimes be partially or fully invisible.
Visit Template:Navbox/doc to edit this documentation. (How does this work?)

This template uses one or more modules written in the Lua programming language.

For more information, see Wikipedia:Lua or the Lua reference manual on mediawiki.org. Modules used include: Navbox.

This template allows a navigational template to be set up relatively quickly by supplying it with one or more lists of links. Using this template is highly recommended for standardization of navigational templates, and for ease of use.

Usage

Please remove the parameters that are left blank.

{{Navbox
| name       = {{subst:PAGENAME}}
| title      =
| listclass  = hlist
| state      = {{{state|}}}

| above      =
| image      =

| group1     =
| list1      =

| group2     =
| list2      =

| group3     =
| list3      =

<!-- ... -->

| below      =
}}

Parameter list

The navbox uses lowercase parameter names, as shown in the box (above). The required name and title will create a one-line box if other parameters are omitted.

Notice "group1" (etc.) is optional, as are sections named "above/below".

The basic and most common parameters are as follows (see below for the full list):

name – the name of the template.
title – text in the title bar, such as: [[Widget stuff]].
class - an optional CSS class for the entire navbox, to enable custom styling.
listclass – a CSS class for the list cells, usually hlist for horizontal lists.
state – controls when a navbox is expanded or collapsed.
above – text to appear above the group/list section (could be a list of overall wikilinks).
image – an optional right-side image, coded as the whole image. Typically it is purely decorative, so it should be coded as [[File:XX.jpg|80px|link=|alt=]].
imageleft – an optional left-side image (code the same as the "image" parameter).
groupn – the left-side text before list-n (if group-n omitted, list-n starts at left of box).
listn – text listing wikilinks using a wikilist format.
below – optional text to appear below the group/list section.

Parameter descriptions

The following is a complete list of parameters for using {{Navbox}}. In most cases, the only required parameters are name, title, and list1.

Setup parameters

name
The name of the template, which is needed for the "V • T • E" ("View • Talk • Edit") links to work properly on all pages where the template is used. You can enter {{subst:PAGENAME}} for this value as a shortcut. The name parameter is only mandatory if a title is specified, and the border parameter is not set, and the navbar parameter is not used to disable the navbar.
state [autocollapse, collapsed, expanded, plain, off]
  • Defaults to autocollapse. A navbox with autocollapse will start out collapsed if there are two or more tables on the same page that use other collapsible tables. Otherwise, the navbox will be expanded.
  • If set to collapsed, the navbox will always start out in a collapsed state.
  • If set to expanded, the navbox will always start out in an expanded state.
  • If set to plain, the navbox will always be expanded with no [hide] link on the right, and the title will remain centered (by using padding to offset the V • T • E links).
  • If set to off, the navbox will always be expanded with no [hide] link on the right, but no padding will be used to keep the title centered. This is for advanced use only; the "plain" option should suffice for most applications where the [show]/[hide] button needs to be hidden.
To show the box when standalone (non-included) but then auto-hide contents when in an article, put "expanded" inside <noinclude|>...</noinclude|> tags. This setting will force the box visible when standalone (even when followed by other boxes), displaying "[hide]", but then it will auto-collapse the box when stacked inside an article:
| state = <noinclude|>expanded</noinclude|>
Often times, editors will want a default initial state for a navbox, which may be overridden in an article. Here is the trick to do this:
  • In your intermediate template, create a parameter also named "state" as a pass-through like this:
| state = {{{state<includeonly>|your_desired_initial_state</includeonly>}}}
  • The <includeonly>| will make the template expanded when viewing the template page by itself.
navbar
If set to plain, the V • T • E links on the left side of the titlebar will not be displayed, and padding will be automatically used to keep the title centered. Use off to remove the V • T • E links, but not apply padding (this is for advanced use only; the "plain" option should suffice for most applications where a navbar is not desired). It is highly recommended that one not hide the navbar, in order to make it easier for users to edit the template, and to keep a standard style across pages.
See later section on using navboxes within one another for examples and a more complete description. If set to child or subgroup, then the navbox can be used as a borderless child that fits snugly in another navbox. The border is hidden and there is no padding on the sides of the table, so it fits into the list area of its parent navbox. If set to none, then the border is hidden and padding is removed, and the navbox may be used as a child of another container (do not use the none option inside of another navbox; similarly, only use the child/subgroup option inside of another navbox). If set to anything else (default), then a regular navbox is displayed with a 1px border. An alternate way to specify the border to be a subgroup style is like this (i.e. use the first unnamed parameter instead of the named border parameter):
{{Navbox|child|...}}

Cells

title*
Text that appears centered in the top row of the table. It is usually the template's topic, i.e. a succinct description of the body contents. This should be a single line, but if a second line is needed, use {{-}} to ensure proper centering. This parameter is technically not mandatory, but using {{Navbox}} is rather pointless without a title.
above*
A full-width cell displayed between the titlebar and first group/list, i.e. above the template's body (groups, lists and image). In a template without an image, above behaves in the same way as the list1 parameter without the group1 parameter.
groupn*
(i.e. group1, group2, etc.) If specified, text appears in a header cell displayed to the left of listn. If omitted, listn uses the full width of the table.
listn*
(i.e. list1, list2, etc.) The body of the template, usually a list of links. Format is inline, although the text can be entered on separate lines if the entire list is enclosed within <div> </div>. At least one list parameter is required; each additional list is displayed in a separate row of the table. Each listn may be preceded by a corresponding groupn parameter, if provided (see below).
Entries should be separated using a newline and an asterisk (*). If instead two asterisks are used, it provides nesting within the previous entry by enclosing the entry with brackets. Increasing the number of asterisks used increases the number of brackets around entries.
imageleft*
An image to be displayed in a cell below the title and to the left of the body (lists). For the image to display properly, the list1 parameter must be specified and no groups can be specified. It accepts the same sort of parameter that image accepts.
below*
A full-width cell displayed below the template's body (groups, lists and image).

Layout of table

Without image, above and below

Table generated by {{Navbox}} without image, above and below parameters:

With image, above and below

Table generated by {{Navbox}} with image, above and below parameters:

With image and without groups

Table generated by {{Navbox}} with image, imageleft, lists, and without groups, above, below:

Examples

TemplateData

Creates a navigational box for links to other pages.

Template parameters

ParameterDescriptionTypeStatus
Namename

The name of the template. Needed for "View • Talk • Edit" links to work properly.

Default
{{subst:PAGENAME}}
Stringsuggested
Titletitle

Text in the title bar; centered in the top row of the table. Usually the template's topic.

Example
[[Template:Navbox]]
Unknownsuggested
Navbox classclass

CSS class for the navbox.

Example
navbox-items
Stringoptional
Group 1group1

If specified, text appears in a header cell displayed to the left of list 1. If omitted, list 1 uses the full width of the table.

Unknownsuggested
List 1list1

Body of the template; usually a list of links. Format is inline. At least one list parameter is required; each additional list is displayed in a separate row of the table. Each listn may be preceded by a corresponding groupn parameter. Entries should be separated using a newline and an asterisk. If two asterisks are used, it provides nesting within the previous entry with brackets.

Unknownrequired
List classlistclass

CSS class for the list cells, usually hlist for horizontal lists.

Example
hlist
Stringoptional
Statestate

Controls when a navbox is expanded or collapsed

Suggested values
autocollapse collapsed expanded plain off
Default
autocollapse
Example
autocollapse
Unknownsuggested
Aboveabove

Full-width cell displayed between the titlebar and first group/list, i.e. above the template's body (groups, lists and image)

Stringsuggested
Belowbelow

Full-width cell displayed below the template's body.

Unknownsuggested
Imageimage

Image to be displayed in a cell below the title and to the right of the body

Example
[[File:XX.jpg | 80px | link= | alt= ]]
Filesuggested
group2group2

no description

Unknownsuggested
list2list2

no description

Unknownsuggested
group3group3

no description

Unknownsuggested
list3list3

no description

Unknownsuggested
group4group4

no description

Unknownoptional
list4list4

no description

Unknownoptional
Image leftimageleft

Image to be displayed in a cell below the title and to the left of the body. For the image to display properly, list1 parameter must be specified and no groups can be specified.

Example
[[File:XX.jpg | 80px | link= | alt= ]]
Fileoptional
Navbar statusnavbar

no description

Example
plain, off
Stringoptional
Border statusborder

no description

Example
child, subgroup, none
Stringoptional
evenoddevenodd

no description

Suggested values
swap even odd off
Unknownoptional