Template:Navbox/doc: Difference between revisions

From Workers & Resources: Soviet Republic Official Wiki
(text editing)
 
m (2 revisions imported)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{documentation subpage}}
{{lua|Navbox}}
{{lua|Module:Navbox}}


{{High-risk}}
This template is used to build [[:Category:Navboxes|navboxes]]. It is highly recommended to use this template only for building other templates, instead of using it on pages directly.
This template allows a [[Help:Templates|navigational template]] to be set up relatively quickly by supplying it one or more lists of links. It comes equipped with default styles that should work for most navigational templates. Changing the default styles is not recommended, but is possible.  Using this template, or one of its "Navbox suite" sister templates, is highly recommended for standardization of navigational templates, and for ease of use.


== Usage ==
CSS styles are defined at:
*[[MediaWiki:Common.css]]


Please remove the parameters that are left blank.
== Features ==
* Supports up to ''unlimited'' rows
** Hides rows without a value
* Supports image and left image
* Supports subheaders
** Subheaders are automatically hidden if they have no rows under them (can be overridden per header)
** Subheaders can be collapsed (configurable per header or globally)
* Fully styled through CSS by default (see [[MediaWiki:Common.css|Common.css]])
* Supports custom styles and classes.
* Alternating row styles (can be disabled)
* Can be run from wikicode (<code>#invoke</code>) or directly in a Module via "<code>require</code>"


<pre style="overflow:auto;">{{Navbox
== Parameters ==
|bodyclass  =  
Here is a list of all supported parameters.
|name      = {{subst:PAGENAME}}
* <sub>(n)</sub> should be replaced by any valid number.
|title      =
* <u>Underlined</u> values are defaults.
|titlestyle =
All parameters are optional.
|image      =
|above      =


|group1    =  
=== Main Parameters ===
|list1      =  
;template/name
:Name of the template, used for VDE (view/discuss/edit) links. Will be passed directly to {{t|vdelinks|style=code}}


|group2    =
;border/''unnamed parameter 1''
|list2      =
:Can be used to control the border of the navbox. Currently only supports the value "child", making the navbox a child navbox of another one.
...
|group20    =
|list20    =


|below      =
;title
}}</pre>
:The main title of the box.


== Parameter list ==
;above
{{Navbox
:Used to add a row that appears above all image, header and data rows.
|name = {{BASEPAGENAME}}
|state = uncollapsed
|image = {{{image}}}
|title = {{{title}}}
|above = {{{above}}}
|group1 = {{{group1}}}
|list1 = {{{list1}}}
|group2 = {{{group2}}}
|list2 = {{{list2}}}
|list3 = {{{list3}}} ''without {{{group3}}}''
|group4 = {{{group4}}}
|list4 = {{{list4}}}
|below = {{{below}}}<br />See alternate navbox formats under: [[#Layout of table|''Layout of table'']]
}}
The navbox uses lowercase parameter names, as shown in the box (''at right'').  The mandatory ''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".
;header<sub>(n)</sub>
{{-}}
:Used to add subheaders to the navbox. Headers are hidden by default unless there are any list rows under them.
The basic and most common parameters are as follows (see below for the full list):


:<code>bodyclass -</code> applies an HTML <code>class</code> attribute to the entire navbox.
;show<sub>(n)</sub> = yes/no
:<code>name -</code> the name of the template.
:Use this parameter to force show/hide a section. The number should correspond to the number of the header that started the section.
:<code>title -</code> text in the title bar, such as: <nowiki>[[Widget stuff]]</nowiki>.
:<code>titleclass -</code> applies an HTML <code>class</code> attribute to the title bar.
:<code>state - autocollapse, uncollapsed, collapsed</code>: the status of box expansion, where "autocollapse" hides stacked navboxes automatically.


:<code>titlestyle - </code>a CSS style for the title-bar, such as: <code>background:gray;</code>
;showall = yes
:<code>groupstyle - </code>a CSS style for the group-cells, such as: <code>background:#eee;</code>
:Use this to force show all sections. Can be overridden with individual <code>show<sub>(n)</sub></code> parameters.


:<code>image - </code>an optional right-side image, coded as the whole image. Typically it is purely decorative, so it should be coded as <code><nowiki>[[Image:</nowiki><var>XX</var><nowiki>.jpg|90px|link=|alt=]]</nowiki></code>.
;group<sub>(n)</sub>
:<code>imageleft - </code>an optional left-side image (code the same as the "image" parameter).
:Contains the group label for a row. If not present, the corresponding list will expand to fill the gap.


:<code>above - </code>text to appear above the group/list section (could be a list of overall wikilinks).
;list<sub>(n)</sub>
:The actual list for the row.


:<code>group<sub>n</sub> - </code>the left-side text before list-n (if group-n omitted, list-n starts at left of box).
;below
:<code>list<sub>n</sub> - </code>text listing wikilinks, often separated by middot templates, such as: [<nowiki />[A]]<code>{<nowiki />{·}}</code> [<nowiki />[B]]
:Used to add a row that appears below all header and data rows.
:<code>below - </code>optional text to appear below the group/list section.


Further details, and complex restrictions, are explained below under section ''[[#Parameter descriptions|Parameter descriptions]]''. See some alternate navbox formats under: [[#Layout of table|''Layout of table'']].
=== Images ===
The navbox supports 2 images (one left and one right). Both images support full syntax (<code><nowiki>[[File:Name.ext|...]]</nowiki></code>) and filename (<code>File:Name.ext</code>). In case of the former, the respective width and link parameters will be ignored.


== Parameter descriptions ==
;image
The following is a complete list of parameters for using {{tl|Navbox}}.  In most cases, the only required parameters are <code>name</code>, <code>title</code>, and <code>list1</code>, though [[Template:Navbox/doc#Child navboxes|child navboxes]] do not even require those to be set.
:Specify an image for the right side


{{tl|Navbox}} shares numerous common parameter names as its sister templates {{tl|Navbox with columns}} and {{tl|Navbox with collapsible groups}} for consistency and ease of use.  Parameters marked with an asterisk <nowiki>*</nowiki> are common to all three master templates.
;imagewidth = <u>100px</u>
:If you didn't use the full syntax, use this to specify the width of the image


=== Setup parameters ===
;imagelink
:; ''name''<nowiki>*</nowiki>
:You can use this to link the image to a certain page.
:: The name of the template, which is needed for the "v{{·}} d{{·}} e" ("view{{·}} discuss{{·}} edit") links to work properly on all pages where the template is used. You can enter <code><nowiki>{{subst:PAGENAME}}</nowiki></code> for this value as a shortcut.  The name parameter is only mandatory if a <code>title</code> is specified, and the <code>border</code> parameter is not set.


:; ''state''<nowiki>*</nowiki> <span style="font-weight:normal;">[<code>autocollapse, uncollapsed, collapsed, plain, off</code>]</span>
;imageleft
:* Defaults to <code>autocollapse</code>. A navbox with <code>autocollapse</code> 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. For the technically minded, see {{Blue|MediaWiki:Common.js}}.
:Specify an image for the left side
:* If set to <code>collapsed</code>, the navbox will always start out in a collapsed state.
:* If set to <code>plain</code>, 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 <small>v • d • e</small> links).
:* If set to <code>off</code>, 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.
:*If set to anything other than <code>autocollapse</code>, <code>collapsed</code>, <code>plain</code>, or <code>off</code> (such as "uncollapsed"), the navbox will always start out in an expanded state, but have the "hide" button.


: To show the box when standalone (non-included) but then auto-hide contents when in an article, put "uncollapsed" inside &lt;noinclude> tags:
;imageleftwidth = <u>100px</u>
:* <code>state = </code><nowiki><noinclude>uncollapsed</noinclude></nowiki>
:Width for the left image
:* That setting will force the box visible when standalone (even when followed by other boxes), displaying "[hide]" but then auto-collapse the box when stacked inside an article.


: 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:
;imageleftlink
:*In your intermediate template, create a parameter also named "state" as a pass-through like this:
:Link for the left image
:*<code><nowiki>| state = {{{state<includeonly>|your_desired_initial_state</includeonly>}}}</nowiki></code>
:*The <nowiki><includeonly>|</nowiki> will make the template expanded when viewing the template page by itself.


:; ''navbar''<nowiki>*</nowiki>
=== Style Parameters ===
:: Defaults to <code>Tnavbar</code>. If set to <code>plain</code>, the <small>v • d • e</small> links on the left side of the titlebar will not be displayed, and padding will be automatically used to keep the title centered.  Use <code>off</code> to remove the <small>v • d • e</small> 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).  Note that it is highly recommended that one does not hide the navbar, in order to make it easier for users to edit the template, and to keep a standard style across pages.
;alternaterows = <u>yes</u>/no/swap
:You can optionally add this to disable alternating row styles. If set to <code>swap</code>, the odd rows will be the alternate rows; otherwise the even rows are.


:; ''border''<nowiki>*</nowiki>
;bodystyle
:: ''See section below on using navboxes within one another for examples and a more complete description.''  If set to <code>child</code> or <code>subgroup</code>, then the navbox can be used as a borderless child that fits snuggly 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 <code>none</code>, 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 <code>none</code> option inside of another navbox; similarly, only use the <code>child</code>/<code>subgroup</code> 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):
;bodyclass
:::<code><nowiki>{{Navbox|child</nowiki></code>
:Classes and styles to add to the navbox itself
::::<code>...</code>
:::<code><nowiki>}}</nowiki></code>


=== Cells ===
;titlestyle
:; ''title''<nowiki>*</nowiki>
;titleclass
:: 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 <code><nowiki>{{-}}</nowiki></code> to ensure proper centering.  This parameter is technically not mandatory, but using {{tl|Navbox}} is rather pointless without a title.
:Classes and styles to add to the title


:; ''group<sub>n</sub>''<nowiki>*</nowiki>
;abovestyle
:: (i.e. ''group1'', ''group2'', etc.) If specified, text appears in a header cell displayed to the left of ''list<sub>n</sub>''. If omitted, ''list<sub>n</sub>'' uses the full width of the table.
;aboveclass
:Classes and styles to add to the above row


:; ''list<sub>n</sub>''<nowiki>*</nowiki>
;imagestyle
::  (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 <code><nowiki><div> </div></nowiki></code>.  At least one ''list'' parameter is required; each additional ''list'' is displayed in a separate row of the table.  Each ''list<sub>n</sub>'' may be preceded by a corresponding ''group<sub>n</sub>'' parameter, if provided (see below).
;imageclass
:Classes and styles to add to the image


:; ''image''<nowiki>*</nowiki>
;imageleftstyle
:: An image to be displayed in a cell below the title and to the right of the body (the groups/lists). For the image to display properly, the ''list1'' parameter must be specified. The ''image'' parameter accepts standard wikicode for displaying an image, ''e.g.'':
;imageleftclass
::: <code><nowiki>[[Image:</nowiki><var>XX</var><nowiki>.jpg|90px|link=|alt=]]</nowiki></code>
:Classes and styles to add to the left image


:; ''imageleft''<nowiki>*</nowiki>
;rowclass
:: 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.
:Classes to add to all list rows


:; ''above''<nowiki>*</nowiki>
;altrowclass = <u>alt</u>
:: 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.
:Classes to add to list rows with alternating styles


:; ''below''<nowiki>*</nowiki>
;groupstyle
:: A full-width cell displayed ''below'' the template's body (groups, lists and image). In a template without an image, ''below'' behaves in the same way as the template's final ''list<sub>n</sub>'' parameter without a ''group<sub>n</sub>'' parameter.
;groupclass
:Classes and styles to add to the groups


=== Style parameters ===
;altgroupstyle
Styles are generally not recommended as to maintain consistency among templates and pages in Wikipedia.  However, the option to modify styles is given.
;altgroupclass
:Classes and styles to add to the groups in alternate rows (if enabled)


:; ''style''<nowiki>*</nowiki>
;liststyle
:: Specifies CSS styles to apply to the template body.  The parameter ''bodystyle'' also does the example same thing and can be used in place of this ''style'' parameter.  This option should be used sparingly as it can lead to visual inconsistencies. Examples:
;listclass
::: <code>style = background:#''nnnnnn'';</code>
:Classes and styles to add to the lists
::: <code>style = width:''N''&nbsp;[em/%/px or width:auto];</code>
::: <code>style = float:[''left/right/none''];</code>
::: <code>style = clear:[''right/left/both/none''];</code>


:; ''basestyle''<nowiki>*</nowiki>
;altliststyle
:: CSS styles to apply to the ''title'', ''above'', ''below'', and ''group'' cells all at once.  The style are not applied to ''list'' cells.  This is convenient for easily changing the basic color of the navbox without having to repeat the style specifications for the different parts of the navbox.  Examples:
;altlistclass
::: <code>basestyle = background:lightskyblue;</code>
:Classes and styles to add to the lists in alternate rows (if enabled)


:; ''titlestyle''<nowiki>*</nowiki>
;belowstyle
:: CSS styles to apply to ''title'', most often the titlebar's background color:
;belowclass
::: <code><nowiki>titlestyle = background:</nowiki>''#nnnnnn'';</code>
:Classes and styles to add to the below row
::: <code><nowiki>titlestyle = background:</nowiki>''name'';</code>


:; ''groupstyle''<nowiki>*</nowiki>
=== Collapsing ===
:: CSS styles to apply to the ''groupN'' cells. This option overrides any styles that are applied to the entire table. Examples:
The Navbox supports two forms of collapsing: for the navbox itself and for individual subsections.
::: <code>groupstyle = background:#''nnnnnn'';</code>
::: <code>groupstyle = text-align:[''left/center/right''];</code>
::: <code>groupstyle = vertical-align:[''top/middle/bottom''];</code>


:; ''group<sub>n</sub>style''<nowiki>*</nowiki>
;state = collapsed/<u>expanded</u>/plain
:: CSS styles to apply to a specific group, in addition to any styles specified by the ''groupstyle'' parameter. This parameter should only be used when absolutely necessary in order to maintain standardization and simplicity.  Examples:
:This parameter controls the collapsing of the navbox itself. If set to <code>collapsed</code>, the box will be collapsed by default. If set to <code>expanded</code>, the box can be collapsed, but will be open by default. If set to <code>plain</code>, the box can not be collapsed and no Show/Hide link will show.
::: <code>group3style = background:red;color:white;</code>


:; ''liststyle''<nowiki>*</nowiki>
;state<sub>(n)</sub> = collapsed/expanded/plain
:: CSS styles to apply to all lists. Overruled by the ''oddstyle'' and ''evenstyle'' parameters (if specified) below. When using backgound colors in the navbox, see the [[#Intricacies|note below]].
:Used to control the collapsing of a single section. A section goes from one header to the next. The number should thus correspond to the one of the header that is above the section to collapse. Options are the same as above.


:; ''list<sub>n</sub>style''<nowiki>*</nowiki>
;defaultstate = collapsed/expanded/<u>plain</u>
:: CSS styles to apply to a specific list, in addition to any styles specified by the ''liststyle'' parameter. This parameter should only be used when absolutely necessary in order to maintain standardization and simplicity.  Examples:
:Sets the default collapse state for the subsections only. Can still be overridden by individual <code>state<sub>(n)</sub></code> parameters.
::: <code>list5style = background:#ddddff;</code>


:; ''listpadding''<nowiki>*</nowiki>
==Examples==
:: A number and unit specifying the padding in each ''list'' cell. The ''list'' cells come equipped with a default padding of 0.25em on the left and right, and 0em on the top and bottom.  Due to complex technical reasons, simply setting "liststyle=padding:0.5em;" (or any other padding setting) will not work. Examples:
===Simple Example===
::: <code>listpadding = 0.5em 0em; </code> (sets 0.5em padding for the left/right, and 0em padding for the top/bottom.)
<pre>{{Navbox
::: <code>listpadding = 0em; </code> (removes all list padding.)
  |title      = A simple navbox
  |template  = Navbox/doc <!-- Used for V D E links -->
|above      = Text to appear on top


:; ''oddstyle''
|group1    = First Group
:; ''evenstyle''
|list1      =
::Applies to odd/even list numbers. Overrules styles defined by ''liststyle''The default behavior is to add striped colors (white and gray) to odd/even rows, respectively, in order to improve readability. These should not be changed except in extraordinary circumstances.
* This
* Is
* How
* You
* Make
* Lists
|group2    = Lists support subitems
|list2      =
* Item 1
** Item 1.1
** Item 1.2
* Item 2
** Item 2.1
  |list3      = List without group (centered)
  |group4    = Group without list (not shown)
|group99999 = 99999th Group
|list99999  = Any number works


:; ''evenodd'' <span style="font-weight:normal;"><code>[swap, even, odd, off]</code></span>
|below      = Text to appear on bottom
:: If set to <code>swap</code>, then the automatic striping of even and odd rows is reversed.  Normally, even rows get a light gray background for striping; when this parameter is used, the odd rows receive the gray striping instead of the even rows.  Setting to <code>even</code> or <code>odd</code> sets all rows to have that striping color.  Setting to <code>off</code> disables automatic row striping.  This advanced parameter should only be used to fix problems when the navbox is being used as a child of another navbox and the stripes do not match up.  Examples and a further description can be found in the section on child navboxes below.
}}</pre>


:; ''abovestyle''<nowiki>*</nowiki>
{{Navbox
:; ''belowstyle''<nowiki>*</nowiki>
|title      = A simple navbox
:: CSS styles to apply to the top cell (specified via the ''above'' parameter) and bottom cell (specified via the ''below'' parameter). Typically used to set background color or text alignment:
|template  = Navbox/doc <!-- Used for V D E links -->
::: <code>abovestyle = background:#''nnnnnn'';</code>
|above      = Text to appear on top
::: <code>abovestyle = text-align:[''left/center/right''];</code>


:; ''imagestyle''<nowiki>*</nowiki>
|group1    = First Group
:; ''imageleftstyle''<nowiki>*</nowiki>
|list1      =
:: CSS styles to apply to the cells where the image/imageleft sitsThese styles should only be used in exceptional circumstances, usually to fix width problems if the width of groups is set and the width of the image cell grows too large. Examples:
* This
::: <code>imagestyle = width:5em;</code>
* Is
* How
* You
* Make
* Lists
|group2    = Lists support subitems
|list2      =
* Item 1
** Item 1.1
** Item 1.2
* Item 2
** Item 2.1
|list3      = List without group (centered)
  |group4    = Group without list (not shown)
  |group99999 = 99999th Group
|list99999  = Any number works


===== Default styles =====
|below      = Text to appear on bottom
The style settings listed here are those that editors using the navbox change most often. The other more complex style settings were left out of this list to keep it simple.  Most styles are set in {{Blue|MediaWiki:Common.css}}.
}}


:<code>bodystyle  = background:#fdfdfd; width:100%; vertical-align:middle;</code>
===Headers Example===
:<code>titlestyle = background:#ccccff; padding-left:1em; padding-right:1em; text-align:center;</code>
<pre>{{Navbox
:<code>abovestyle = background:#ddddff; padding-left:1em; padding-right:1em; text-align:center;</code>
  |title  = Navbox with subheaders
:<code>belowstyle = background:#ddddff; padding-left:1em; padding-right:1em; text-align:center;</code>
:<code>groupstyle = background:#ddddff; padding-left:1em; padding-right:1em; text-align:right;</code>
:<code>liststyle  = background:transparent; text-align:left/center;</code>
:<code>oddstyle  = background:transparent;</code>
:<code>evenstyle = background:#f7f7f7;</code>


Since ''liststyle'' and ''oddstyle'' are transparent odd lists have the color of the ''bodystyle'', which defaults to #fdfdfd (white with a hint of gray). A list has <code>text-align:left;</code> if it has a group, if not it has <code>text-align:center;</code>. Since only ''bodystyle'' has a vertical-align all the others inherit its <code>vertical-align:middle;</code>.
|group1  = First Group
|list1  = This list is before the first header


=== Advanced parameters ===
|header2 = Header for section 2
:; ''titlegroup''
|group2  = Second Group
:: This puts a group in the title area, with the same default styles as ''group<sub>n</sub>''. It should  be used only in exceptional circumstances (usually advanced meta-templates) and its use requires some knowledge of the internal code of {{tl|Navbox}}; you should be ready to manually set up CSS styles to get everything to work properly if you wish to use it.  If you think you have an application for this parameter, it might be best to change your mind, or consult the talk page first.
|list2  = Second List (part of section 2)
|group3  = Third Group
  |list3  = Third List (also part of section 2)


:; ''titlegroupstyle''
|header4 = Header with no lists (Not shown)
:: The styles for the titlegroup cell.


:; ''innerstyle''
|header5 = Another Header
:: A very advanced parameter to be used ''only'' for advanced meta-templates employing the navbox. Internally, the navbox uses an outer table to draw the border, and then an inner table for everything else (title/above/groups/lists/below/images, etc.).  The ''style''/''bodystyle'' parameter sets the style for the outer table, which the inner  table inherits, but in advanced cases (meta-templates) it may be necessary to directly set the style for the inner table.  This parameter provides access to that inner table so styles can be applied.  Use at your own risk.
  |list5  = Another list (part of section 5)


====Microformats====
|header6 = Another header with no lists (force shown)
;bodyclass : This parameter is inserted into the "class" attribute for the infobox as a whole.
|show6  = yes
;titleclass : This parameter is inserted into the "class" attribute for the infobox's title caption.


This template supports the addition of microformat information. This is done by adding "class" attributes to various data cells, indicating what kind of information is contained within. To flag a navbox as containing [[w:hCard|hCard]] information about a person, for example, add the following parameter:
|header7 = A header with a list that is force hidden
|list7  = Not shown either
|show7  = no
}}</pre>


<pre>
{{Navbox
|bodyclass = vcard
|title  = Navbox with subheaders
</pre>


''and''
|group1  = First Group
|list1  = This list is before the first header


<pre>
|header2 = Header for section 2
|titleclass = fn
|group2  = Second Group
</pre>
|list2  = Second List (part of section 2)
|group3  = Third Group
|list3  = Third List (also part of section 2)


''or'' (for example):
|header4 = Header with no lists (Not shown)


<pre><nowiki>
|header5 = Another Header
|title = The books of <span class="fn">[[Iain Banks]]</span>
|list5  = Another list (part of section 5)
</nowiki></pre>


...and so forth.
|header6 = Another header with no lists (force shown)
|show6  = yes


== Layout of table ==
|header7 = A header with a list that is force hidden
Table generated by {{tl|Navbox}} '''without''' ''image'', ''above'' and ''below'' parameters (gray list background color added for illustration only):
|list7  = Not shown either
{{Navbox
|show7  = no
|name = Navbox/doc
|state = uncollapsed
|liststyle = background:silver;
|title = {{{title}}}
|group1 = {{{group1}}}
|list1 = {{{list1}}}
|group2 = {{{group2}}}
|list2 = {{{list2}}}
|list3 = {{{list3}}} ''without {{{group3}}}''
|group4 = {{{group4}}}
|list4 = {{{list4}}}
}}
}}


===Images Example===
<pre>{{Navbox
|title      = Navbox with images
|group1    = First Group
|list1      = First List
|header2    = Some Header
|list2      = Some List
|image      = File:Wiki.png
|imagewidth = 60px
|imagelink  = w:
|imageleft  = [[File:Example.jpg|50px]]
|below      = Below goes below images too
}}</pre>


Table generated by {{tl|Navbox}} '''with''' ''image'', ''above'' and ''below'' parameters (gray list background color added for illustration only):
{{Navbox
{{Navbox
|name = Navbox/doc
|title      = Navbox with images
|state = uncollapsed
 
|liststyle = background:silver;
|group1    = First Group
|image = {{{image}}}
|list1      = First List
|title = {{{title}}}
 
|above = {{{above}}}
|header2    = Some Header
|group1 = {{{group1}}}
|list2      = Some List
|list1 = {{{list1}}}
|group2 = {{{group2}}}
|image      = File:Wiki.png
|list2 = {{{list2}}}
|imagewidth = 60px
|list3 = {{{list3}}} ''without {{{group3}}}''
|imagelink  = w:
|group4 = {{{group4}}}
|list4 = {{{list4}}}
|imageleft  = [[File:Example.jpg|50px]]
|below = {{{below}}}
|below     = Below goes below images too
}}
}}


===Collapsing Example===
<pre>{{Navbox
|title  = Navbox with collapsing
|state  = collapsed
|header1 = First Header (Plain)
|group1  = First Group
|list1  = This list is before the first header
|group2  = Second Group
|list2  = Second List
|header3 = Second Header (Expanded)
|state3  = expanded
|group3  = Third Group
|list3  = Third List
|group4  = Fourth Group
|list4  = Fourth List
|header5 = Third Header (Collapsed)
|state5  = collapsed
|group5  = Fifth Group
|list5  = Fifth List
|group6  = Sixth Group
|list6  = Sixth List
}}</pre>


Table generated by {{tl|Navbox}} '''with''' ''image'', ''imageleft'', ''lists'', and '''without''' ''groups'', ''above'', ''below'' (gray list background color added for illustration only):
{{Navbox
{{Navbox
|name = Navbox/doc
|title  = Navbox with collapsing
|state = uncollapsed
|state   = collapsed
|liststyle = background:silver;
|image = {{{image}}}
|header1 = First Header (Plain)
|imageleft = {{{imageleft}}}
|group1  = First Group
|title = {{{title}}}
|list1  = This list is before the first header
|list1 = {{{list1}}}
|group2  = Second Group
|list2 = {{{list2}}}
|list2  = Second List
|list3 = {{{list3}}}
|list4 = {{{list4}}}
|header3 = Second Header (Expanded)
|state3  = expanded
|group3  = Third Group
|list3   = Third List
|group4  = Fourth Group
|list4   = Fourth List
|header5 = Third Header (Collapsed)
|state5  = collapsed
|group5  = Fifth Group
|list5  = Fifth List
|group6  = Sixth Group
|list6  = Sixth List
}}
}}


== Technical details ==
===Custom Styles Example===
Example using wikipedia style colors. The values represent CSS classes.
 
Note: It is recommended to use the classes over the styles if possible. To view/edit the default styles, see [[MediaWiki:Common.css]]
 
<pre>{{Navbox
|title        = .navbox-title
|above        = .navbox-above
 
|header1      = .navbox-header
|group1      = .navbox-row-group
|list1        = .navbox-row-list
|group2      = .alt .navbox-row-group
|list2        = .alt .navbox-row-list
|list3        = .navbox-list.no-group
 
|below        = .navbox-below
|bodystyle    = background: #fdfdfd; color: black; border: 1px solid #aaa; padding: 3px
|titlestyle  = background: #ccf; color: black
|abovestyle  = background: #ddf; color: black
|headerstyle  = background: #ddf; color: black
|groupstyle  = background: #ddf; border-right: 2px solid white; color: black; text-align: right; padding-right: 1em
|liststyle    = background: transparent; color: black
|altliststyle = background: #f7f7f7; color: black
|belowstyle  = background: #ddf; color: black
}}</pre>


*This template uses CSS classes for most of its looks, thus it is fully skinnable.
{{Navbox
*Internally this meta template uses HTML markup instead of wiki markup for the table code. That is the usual way we make meta templates since wiki markup has several drawbacks. For instance it makes it harder to use [[m:Help:ParserFunctions|parser functions]] and special characters in parameters.
|title        = .navbox-title
*For more technical details see the CSS classes in {{Blue|MediaWiki:Common.css}} and the collapsible table used to hide the box in {{Blue|MediaWiki:Common.js}}.
|above        = .navbox-above


=== Intricacies ===
|header1      = .navbox-header
|group1      = .navbox-row-group
|list1        = .navbox-row-list
|group2      = .alt .navbox-row-group
|list2        = .alt .navbox-row-list
|list3        = .navbox-list.no-group


*The 2px wide border between groups and lists is drawn using the border-left property of the list cell. Thus, if you wish to change the background color of the template (for example <code>bodystyle = background:purple;</code>), then you'll need to make the border-left-color match the background color (i.e. <code>liststyle = border-left-color:purple;</code>).  If you wish to have a border around each list cell, then the 2px border between the list cells and group cells will disappear; you'll have to come up with your own solution.
|below        = .navbox-below
*The list cell width is initially set to 100%. Thus, if you wish to manually set the width of group cells, you'll need to also specify the liststyle to have width:auto.  If you wish to set the group width and use images, it's up to you to figure out the CSS in the groupstyle, liststyle, imagestyle, and imageleftstyle parameters to get everything to work correctly.  Example of setting group width:
::<code>groupstyle = width:10em;</code>
  |bodystyle   = background: #fdfdfd; color: black; border: 1px solid #aaa; padding: 3px
::<code>liststyle = width:auto;</code>
  |titlestyle  = background: #ccf; color: black
*Adjacent navboxes have only a 1 pixel border between them (except in IE6, which doesn't support the necessary CSS).  If you set the top or bottom margin of <code>style/bodystyle</code>, then this will not work.
|abovestyle  = background: #ddf; color: black
*The default margin-left and margin-right of the outer navbox table are set to "auto;".  If you wish to use navbox as a float, you need to manually set the margin-left and margin-right values, because the auto margins interfere with the float option.  For example, add the following code to use the navbox as a float:
|headerstyle  = background: #ddf; color: black
::<code>style = width:22em;float:right;margin-left:1em;margin-right:0em;</code>
|groupstyle  = background: #ddf; border-right: 2px solid white; color: black; text-align: right; padding-right: 1em
|liststyle    = background: transparent; color: black
|altliststyle = background: #f7f7f7; color: black
|belowstyle  = background: #ddf; color: black
}}


== TemplateData ==
===Subgroups Example===
{{TemplateData header}}
<pre>{{Navbox
<templatedata>
|title   = Navbox with subgroups
{
|group1 = Normal group
"format": "block",
|list1   = Normal list
"description": {
|group2 = Subgrouped
"en": "This template allows a navigational template to be set up relatively quickly by supplying it one or more lists of links.",
|list2   = {{Navbox|child
"cs": "Tato šablona umožňuje poměrně rychle nastavit navigační šablonu tím, že jí poskytne jeden nebo více seznamů odkazů."
  |group1 = First subgroup
},
  |list1 = List goes here
"params": {
  |group2 = Second...
"image": {
  |list2 = Another list
"label": {
  |image  = [[File:Example.jpg|48px]] <!-- An image for this group -->
"en": "Image",
  |alternaterows = swap <!-- Makes box start with an alt row -->
"cs": "Obraz"
}}
},
}}</pre>
"type": "wiki-file-name"
},
"imageleft": {
"label": {
"en": "Image left",
"cs": "Obrázek vlevo"
},
"type": "wiki-file-name"
},
"name": {
"label": {
"en": "Template Name",
"cs": "Název šablony"
},
"description": {
"en": "The name of the template that creates this navbox.",
"cs": "Název šablony, která vytváří toto navigační pole."
},
"autovalue": "{{subst:PAGENAME}}",
"suggested": true,
"type": "wiki-template-name"
},
"title": {
"label": {
"en": "Title",
"cs": "Titul"
},
"type": "string"
},
"above": {
"label": {
"en": "Content above",
"cs": "Obsah výše"
},
"type": "content"
},
"group1": {
"label": {
"en": "Group #1",
"cs": "Skupina 1"
},
"type": "string"
},
"list1": {
"label": {
"en": "List #1",
"cs": "Seznam 1"
},
"type": "content"
},
"group2": {
"label": {
"en": "Group 2",
"cs": "Skupina 2"
},
"type": "string"
},
"list2": {
"label": {
"en": "List #2",
"cs": "Seznam 2"
},
"type": "content"
},
"list3": {
"label": {
"en": "List #3",
"cs": "Seznam 3"
},
"type": "content"
},
"group3": {
"label": {
"en": "Group #3",
"cs": "Skupina 3"
},
"type": "string"
},
"group4": {
"label": {
"en": "Group #4",
"cs": "Skupina 4"
},
"type": "string"
},
"list4": {
"label": {
"en": "List #4",
"cs": "Seznam 4"
},
"type": "content"
},
"group5": {
"label": {
"en": "Group #5",
"cs": "Skupina 5"
},
"type": "string"
},
"list5": {
"label": {
"en": "List #5",
"cs": "Seznam 5"
},
"type": "content"
},
"group6": {
"label": {
"en": "Group #6",
"cs": "Skupina 6"
},
"type": "string"
},
"list6": {
"label": {
"en": "List #6",
"cs": "Seznam 6"
},
"type": "content"
},
"group7": {
"label": {
"en": "Group #7",
"cs": "Skupina 7"
},
"type": "string"
},
"list7": {
"label": {
"en": "List #7",
"cs": "Seznam 7"
},
"type": "content"
},
"group8": {
"label": {
"en": "Group #8",
"cs": "Skupina 8"
},
"type": "string"
},
"list8": {
"label": {
"en": "List #8",
"cs": "Seznam 8"
},
"type": "content"
},
"group9": {
"label": {
"en": "Group #9",
"cs": "Skupina 9"
},
"type": "string"
},
"list9": {
"label": {
"en": "List #9",
"cs": "Seznam 9"
},
"type": "content"
},
"group10": {
"label": {
"en": "Group #10",
"cs": "Skupina 10"
},
"type": "string"
},
"list10": {
"label": {
"en": "List #10",
"cs": "Seznam 10"
},
"type": "content"
},
"group11": {
"label": {
"en": "Group #11",
"cs": "Skupina 11"
},
"type": "string"
},
"list11": {
"label": {
"en": "List #11",
"cs": "Seznam 11"
},
"type": "content"
},
"group12": {
"label": {
"en": "Group #12",
"cs": "Skupina 12"
},
"type": "string"
},
"list12": {
"label": {
"en": "List #12",
"cs": "Seznam 12"
},
"type": "content"
},
"group13": {
"label": {
"en": "Group #13",
"cs": "Skupina 13"
},
"type": "string"
},
"list13": {
"label": {
"en": "List #13",
"cs": "Seznam 13"
},
"type": "content"
},
"group14": {
"label": {
"en": "Group #14",
"cs": "Skupina 14"
},
"type": "string"
},
"list14": {
"label": {
"en": "List #14",
"cs": "Seznam 14"
},
"type": "content"
},
"group15": {
"label": {
"en": "Group #15",
"cs": "Skupina 15"
},
"type": "string"
},
"list15": {
"label": {
"en": "List #15",
"cs": "Seznam 15"
},
"type": "content"
},
"group16": {
"label": {
"en": "Group #16",
"cs": "Skupina 16"
},
"type": "string"
},
"list16": {
"label": {
"en": "List #16",
"cs": "Seznam 16"
},
"type": "content"
},
"group17": {
"label": {
"en": "Group #17",
"cs": "Skupina 17"
},
"type": "string"
},
"list17": {
"label": {
"en": "List #17",
"cs": "Seznam 17"
},
"type": "content"
},
"group18": {
"label": {
"en": "Group #18",
"cs": "Skupina 18"
},
"type": "string"
},
"list18": {
"label": {
"en": "List #18",
"cs": "Seznam 18"
},
"type": "content"
},
"group19": {
"label": {
"en": "Group #19",
"cs": "Skupina 19"
},
"type": "string"
},
"list19": {
"label": {
"en": "List #19",
"cs": "Seznam 19"
},
"type": "content"
},
"group20": {
"label": {
"en": "Group #20",
"cs": "Skupina 20"
},
"type": "string"
},
"list20": {
"label": {
"en": "List #20",
"cs": "Seznam 20"
},
"type": "content"
},
"below": {
"label": {
"en": "Content below",
"cs": "Obsah níže"
},
"type": "content"
}
},
"paramOrder": [
"name",
"title",
"image",
"imageleft",
"above",
"group1",
"list1",
"group2",
"list2",
"group3",
"list3",
"group4",
"list4",
"group5",
"list5",
"group6",
"list6",
"group7",
"list7",
"group8",
"list8",
"group9",
"list9",
"group10",
"list10",
"group11",
"list11",
"group12",
"list12",
"group13",
"list13",
"group14",
"list14",
"group15",
"list15",
"group16",
"list16",
"group17",
"list17",
"group18",
"list18",
"group19",
"list19",
"group20",
"list20",
"below"
]
}
</templatedata>
<includeonly>{{Sandbox other||
<!--Categories-->
[[Category:Formatting templates| ]]


<!--Other languages-->
{{Navbox
}}</includeonly>
|title  = Navbox with subgroups
|group1  = Normal group
|list1  = Normal list
|group2  = Subgrouped
|list2  = {{Navbox|child
  |group1 = First subgroup
  |list1  = List goes here
  |group2 = Second...
  |list2  = Another list
  |image  = [[File:Example.jpg|48px]]
  |alternaterows = swap
}}
}}

Latest revision as of 19:25, 14 June 2024

Lua error in package.lua at line 80: module 'Dev:Arguments' not found.

This template is used to build navboxes. It is highly recommended to use this template only for building other templates, instead of using it on pages directly.

CSS styles are defined at:

Features

  • Supports up to unlimited rows
    • Hides rows without a value
  • Supports image and left image
  • Supports subheaders
    • Subheaders are automatically hidden if they have no rows under them (can be overridden per header)
    • Subheaders can be collapsed (configurable per header or globally)
  • Fully styled through CSS by default (see Common.css)
  • Supports custom styles and classes.
  • Alternating row styles (can be disabled)
  • Can be run from wikicode (#invoke) or directly in a Module via "require"

Parameters

Here is a list of all supported parameters.

  • (n) should be replaced by any valid number.
  • Underlined values are defaults.

All parameters are optional.

Main Parameters

template/name
Name of the template, used for VDE (view/discuss/edit) links. Will be passed directly to {{vdelinks}}
border/unnamed parameter 1
Can be used to control the border of the navbox. Currently only supports the value "child", making the navbox a child navbox of another one.
title
The main title of the box.
above
Used to add a row that appears above all image, header and data rows.
header(n)
Used to add subheaders to the navbox. Headers are hidden by default unless there are any list rows under them.
show(n) = yes/no
Use this parameter to force show/hide a section. The number should correspond to the number of the header that started the section.
showall = yes
Use this to force show all sections. Can be overridden with individual show(n) parameters.
group(n)
Contains the group label for a row. If not present, the corresponding list will expand to fill the gap.
list(n)
The actual list for the row.
below
Used to add a row that appears below all header and data rows.

Images

The navbox supports 2 images (one left and one right). Both images support full syntax ([[File:Name.ext|...]]) and filename (File:Name.ext). In case of the former, the respective width and link parameters will be ignored.

image
Specify an image for the right side
imagewidth = 100px
If you didn't use the full syntax, use this to specify the width of the image
imagelink
You can use this to link the image to a certain page.
imageleft
Specify an image for the left side
imageleftwidth = 100px
Width for the left image
imageleftlink
Link for the left image

Style Parameters

alternaterows = yes/no/swap
You can optionally add this to disable alternating row styles. If set to swap, the odd rows will be the alternate rows; otherwise the even rows are.
bodystyle
bodyclass
Classes and styles to add to the navbox itself
titlestyle
titleclass
Classes and styles to add to the title
abovestyle
aboveclass
Classes and styles to add to the above row
imagestyle
imageclass
Classes and styles to add to the image
imageleftstyle
imageleftclass
Classes and styles to add to the left image
rowclass
Classes to add to all list rows
altrowclass = alt
Classes to add to list rows with alternating styles
groupstyle
groupclass
Classes and styles to add to the groups
altgroupstyle
altgroupclass
Classes and styles to add to the groups in alternate rows (if enabled)
liststyle
listclass
Classes and styles to add to the lists
altliststyle
altlistclass
Classes and styles to add to the lists in alternate rows (if enabled)
belowstyle
belowclass
Classes and styles to add to the below row

Collapsing

The Navbox supports two forms of collapsing: for the navbox itself and for individual subsections.

state = collapsed/expanded/plain
This parameter controls the collapsing of the navbox itself. If set to collapsed, the box will be collapsed by default. If set to expanded, the box can be collapsed, but will be open by default. If set to plain, the box can not be collapsed and no Show/Hide link will show.
state(n) = collapsed/expanded/plain
Used to control the collapsing of a single section. A section goes from one header to the next. The number should thus correspond to the one of the header that is above the section to collapse. Options are the same as above.
defaultstate = collapsed/expanded/plain
Sets the default collapse state for the subsections only. Can still be overridden by individual state(n) parameters.

Examples

Simple Example

{{Navbox
 |title      = A simple navbox
 |template   = Navbox/doc <!-- Used for V D E links -->
 |above      = Text to appear on top

 |group1     = First Group
 |list1      = 
* This
* Is
* How
* You
* Make
* Lists
 |group2     = Lists support subitems 
 |list2      =
* Item 1
** Item 1.1
** Item 1.2
* Item 2
** Item 2.1
 |list3      = List without group (centered)
 |group4     = Group without list (not shown)
 |group99999 = 99999th Group
 |list99999  = Any number works

 |below      = Text to appear on bottom
}}

Headers Example

{{Navbox
 |title   = Navbox with subheaders

 |group1  = First Group
 |list1   = This list is before the first header

 |header2 = Header for section 2
 |group2  = Second Group
 |list2   = Second List (part of section 2)
 |group3  = Third Group
 |list3   = Third List (also part of section 2)

 |header4 = Header with no lists (Not shown)

 |header5 = Another Header
 |list5   = Another list (part of section 5)

 |header6 = Another header with no lists (force shown)
 |show6   = yes

 |header7 = A header with a list that is force hidden
 |list7   = Not shown either
 |show7   = no
}}

Images Example

{{Navbox
 |title      = Navbox with images

 |group1     = First Group
 |list1      = First List

 |header2    = Some Header
 |list2      = Some List
 
 |image      = File:Wiki.png
 |imagewidth = 60px
 |imagelink  = w:
 
 |imageleft  = [[File:Example.jpg|50px]]
 
 |below      = Below goes below images too
}}

Collapsing Example

{{Navbox
 |title   = Navbox with collapsing
 |state   = collapsed
 
 |header1 = First Header (Plain)
 |group1  = First Group
 |list1   = This list is before the first header
 |group2  = Second Group
 |list2   = Second List
 
 |header3 = Second Header (Expanded)
 |state3  = expanded
 |group3  = Third Group
 |list3   = Third List
 |group4  = Fourth Group
 |list4   = Fourth List
 
 |header5 = Third Header (Collapsed)
 |state5  = collapsed
 |group5  = Fifth Group
 |list5   = Fifth List
 |group6  = Sixth Group
 |list6   = Sixth List
}}

Custom Styles Example

Example using wikipedia style colors. The values represent CSS classes.

Note: It is recommended to use the classes over the styles if possible. To view/edit the default styles, see MediaWiki:Common.css

{{Navbox
 |title        = .navbox-title
 |above        = .navbox-above

 |header1      = .navbox-header
 |group1       = .navbox-row-group
 |list1        = .navbox-row-list
 |group2       = .alt .navbox-row-group
 |list2        = .alt .navbox-row-list
 |list3        = .navbox-list.no-group

 |below        = .navbox-below
 
 |bodystyle    = background: #fdfdfd; color: black; border: 1px solid #aaa; padding: 3px
 |titlestyle   = background: #ccf; color: black
 |abovestyle   = background: #ddf; color: black
 |headerstyle  = background: #ddf; color: black
 |groupstyle   = background: #ddf; border-right: 2px solid white; color: black; text-align: right; padding-right: 1em
 |liststyle    = background: transparent; color: black
 |altliststyle = background: #f7f7f7; color: black
 |belowstyle   = background: #ddf; color: black
}}

Subgroups Example

{{Navbox
 |title   = Navbox with subgroups
 |group1  = Normal group
 |list1   = Normal list
 |group2  = Subgrouped
 |list2   = {{Navbox|child
  |group1 = First subgroup
  |list1  = List goes here
  |group2 = Second...
  |list2  = Another list
  |image  = [[File:Example.jpg|48px]] <!-- An image for this group -->
  |alternaterows = swap <!-- Makes box start with an alt row -->
 }}
}}