Template:Navbox/doc: Difference between revisions
dlw>RheingoldRiver No edit summary |
Verdite cat (talk | contribs) m 1 revision imported |
(No difference)
|
Latest revision as of 18:53, 12 September 2024
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, usuallyhlist
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 atitle
is specified, and theborder
parameter is not set, and thenavbar
parameter is not used to disable the navbar. - state [
autocollapse, collapsed, expanded, plain, off
]
- Defaults to
autocollapse
. A navbox withautocollapse
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. Useoff
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
orsubgroup
, 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 tonone
, then the border is hidden and padding is removed, and the navbox may be used as a child of another container (do not use thenone
option inside of another navbox; similarly, only use thechild
/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.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Name | name | The name of the template. Needed for "View • Talk • Edit" links to work properly.
| String | suggested |
Title | title | Text in the title bar; centered in the top row of the table. Usually the template's topic.
| Unknown | suggested |
Navbox class | class | CSS class for the navbox.
| String | optional |
Group 1 | group1 | 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. | Unknown | suggested |
List 1 | list1 | 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. | Unknown | required |
List class | listclass | CSS class for the list cells, usually hlist for horizontal lists.
| String | optional |
State | state | Controls when a navbox is expanded or collapsed
| Unknown | suggested |
Above | above | Full-width cell displayed between the titlebar and first group/list, i.e. above the template's body (groups, lists and image) | String | suggested |
Below | below | Full-width cell displayed below the template's body. | Unknown | suggested |
Image | image | Image to be displayed in a cell below the title and to the right of the body
| File | suggested |
group2 | group2 | no description | Unknown | suggested |
list2 | list2 | no description | Unknown | suggested |
group3 | group3 | no description | Unknown | suggested |
list3 | list3 | no description | Unknown | suggested |
group4 | group4 | no description | Unknown | optional |
list4 | list4 | no description | Unknown | optional |
Image left | imageleft | 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.
| File | optional |
Navbar status | navbar | no description
| String | optional |
Border status | border | no description
| String | optional |
evenodd | evenodd | no description
| Unknown | optional |