The editors' meeting has been canceled for technical reasons.
Template:Navbox/doc: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<!-- | <!-- Below is the English-translated version of the code, suitable for direct pasting into the English Wikipedia. --> | ||
<!-- Edit the template documentation below this line --> | |||
This template allows for relatively convenient and quick summarization of similar types of entries to create a navigation template (referred to here as [[:Category:Navbox templates]]). | |||
== | This template is highly customizable and can be used in combination with {{tl|Navbox subgroup}}, {{tl|Navbox with columns}}, and {{tl|Navbox with collapsible groups}}. | ||
== Common Parameters == | |||
; <kbd>name</kbd> | ; <kbd>name</kbd> | ||
: | : The name of the template (the part after "Template:", not the title of the template), e.g., "Attributes". | ||
; <kbd>title</kbd> | ; <kbd>title</kbd> | ||
: | : The text in the title bar, e.g., "[[Attributes]] • [[List of attributes]]". It does not have to match <code>name</code>. | ||
; <kbd>state</kbd> | ; <kbd>state</kbd> | ||
: <code>[mw-uncollapsed, mw-collapsed]</code> | : <code>[mw-uncollapsed, mw-collapsed]</code> | ||
: | : The initial collapse state of the box. | ||
; <kbd>titlestyle</kbd> | ; <kbd>titlestyle</kbd>, <kbd>groupstyle</kbd>, <kbd>evenstyle</kbd> | ||
: | : CSS styles for the title bar, groups, and even-numbered lists (default light green), respectively, e.g., <code>background:gray</code>. | ||
; <kbd>above</kbd> | ; <kbd>above</kbd> | ||
: | : Content displayed above the group/list section. | ||
; <kbd>group<sub>n</sub></kbd> | ; <kbd>group<sub>n</sub></kbd> | ||
: | : The text on the left, appearing before list<sub>n</sub> (if group<sub>n</sub> is omitted, list<sub>n</sub> starts at the left edge of the box). | ||
; <kbd>list<sub>n</sub></kbd> | ; <kbd>list<sub>n</sub></kbd> | ||
: | : Text listing wiki links, typically separated by bullet points, e.g., <nowiki>[[A]] • [[B]] • …</nowiki>. | ||
; <kbd>below</kbd> | ; <kbd>below</kbd> | ||
: | : Optional text displayed below the group/list section. | ||
{{Hide| | {{Hide|Source code with common parameters, which can be copied for quick creation of a navigation template| | ||
Remove unused parameters; do not retain them unnecessarily. | |||
<pre> | <pre> | ||
{{Navbox | {{Navbox | ||
Line 65: | Line 67: | ||
</pre>}} | </pre>}} | ||
---- | ---- | ||
Most other parameters for Navbox are not commonly used, so two simplified templates have been created for the most common parameters: {{tl|Navbox family}} and {{tl|Navbox family row}} ({{tl|Links}}). | |||
Examples of some commonly used parameters can be found under [[#Layout of the table]] and [[#Examples]]. Detailed explanations and complex constraints are provided in the [[#Parameter descriptions]] section below. | |||
== | == Parameter Descriptions == | ||
{{FromOther|sect=sect|site= | {{FromOther|sect=sect|site=Wikipedia (en)|originURL=https://en.wikipedia.org/wiki/{{FULLPAGENAMEE:Template:Navbox/doc}}|origin=Template:Navbox/doc|copyright=cc|lsubtype=by-sa|lver=3.0|contribURL=https://en.wikipedia.org/w/index.php?title={{FULLPAGENAMEE:Template:Navbox/doc}}&action=history|demo=}} | ||
Below is a complete list of parameters for {{tl|Navbox}}. In most cases, only the <code>name</code>, <code>title</code>, and <code>list1</code> parameters are needed, though [[#Sub-navboxes|sub-navboxes]] may not require even these. | |||
{{tl|Navbox}} | {{tl|Navbox}} shares many common parameters with its sister templates {{tl|Navbox with columns}} and {{tl|Navbox with collapsible groups}} to enhance consistency and usability. Parameters marked with a "<kbd style="font-weight:bold"><sup>†</sup></kbd>" are applicable to all three main templates. | ||
=== | === Configuration Parameters === | ||
; <kbd>name<sup>†</sup></kbd> | ; <kbd>name<sup>†</sup></kbd> | ||
: | : The name of the template. To ensure the "view • talk • edit" links work correctly on all pages using the template, this parameter needs to be set. You can use <code><nowiki>{{subst:PAGENAME}}</nowiki></code> as the value for this parameter as a shortcut. This parameter is required. | ||
; <kbd>state<sup>†</sup></kbd> | ; <kbd>state<sup>†</sup></kbd> | ||
: <code>[mw-uncollapsed, mw-collapsed, plain, off]</code> | : <code>[mw-uncollapsed, mw-collapsed, plain, off]</code> | ||
<!--:* | <!--:* Defaults to <code>autocollapse</code>. If two or more collapsible tables are on the same page, navboxes with <code>autocollapse</code> will be collapsed by default. Otherwise, the navbox will be expanded. See [[MediaWiki:Common.js]] for technical implementation details. --> | ||
:* | :* If set to <code>mw-collapsed</code>, the navbox will always appear collapsed by default. | ||
:* | :* If set to <code>plain</code>, the navbox will always be expanded without a "hide" link on the right, with the title centered (via padding to offset the "view • talk • edit" links). | ||
:* | :* If set to <code>off</code>, the navbox will always be expanded without a "hide" link, but no padding will be applied to center the title. This option is for advanced use; the "plain" option should suffice for most cases where the "show"/"hide" buttons need to be removed. | ||
:* | :* For any other value (e.g., "mw-uncollapsed"), the navbox will always appear expanded by default, with a "hide" button. | ||
<!-- Additional parameter descriptions truncated for brevity. --> | |||
=== Style Parameters === | |||
=== | |||
; <kbd>style<sup>†</sup></kbd> | ; <kbd>style<sup>†</sup></kbd> | ||
: | : Specifies CSS styles applied to the main body of the template. The <kbd>bodystyle</kbd> parameter achieves the same effect as this <kbd>style</kbd> parameter and can be used as a substitute. This option should be used with caution as it may cause visual inconsistencies. Examples: | ||
:* <code>style = background:#''nnnnnn'';</code> | :* <code>style = background:#''nnnnnn'';</code> | ||
:* <code>style = width:''N'' [em/%/px or width:auto];</code> | :* <code>style = width:''N'' [em/%/px or width:auto];</code> | ||
Line 139: | Line 99: | ||
; <kbd>titlestyle<sup>†</sup></kbd> | ; <kbd>titlestyle<sup>†</sup></kbd> | ||
: | : CSS styles applied to the <kbd>title</kbd>, often used to customize the background color of the navigation bar: | ||
:* <code>titlestyle = background:''#nnnnnn'';</code> | :* <code>titlestyle = background:''#nnnnnn'';</code> | ||
:* <code>titlestyle = background:''name'';</code> | :* <code>titlestyle = background:''name'';</code> | ||
; <kbd>groupstyle<sup>†</sup></kbd> | ; <kbd>groupstyle<sup>†</sup></kbd> | ||
: | : CSS styles applied to all <kbd>group</kbd> cells. This option overrides any styles applied to the entire table. Examples: | ||
:* <code>groupstyle = background:#''nnnnnn'';</code> | :* <code>groupstyle = background:#''nnnnnn'';</code> | ||
:* <code>groupstyle = text-align:[''left/center/right''];</code> | :* <code>groupstyle = text-align:[''left/center/right''];</code> | ||
Line 150: | Line 110: | ||
; <kbd>group<sub>n</sub>style<sup>†</sup></kbd> | ; <kbd>group<sub>n</sub>style<sup>†</sup></kbd> | ||
: | : CSS styles applied to specific <kbd>groupN</kbd>. This has the highest priority and allows different groups to have unique styles. | ||
; <kbd>liststyle<sup>†</sup></kbd> | ; <kbd>liststyle<sup>†</sup></kbd> | ||
: | : CSS styles applied to all <kbd>list</kbd> items. If <kbd>list<sub>n</sub>style</kbd>, <kbd>oddstyle</kbd>, or <kbd>evenstyle</kbd> parameters are specified, they take precedence over this parameter. | ||
; <kbd>list<sub>n</sub>style<sup>†</sup></kbd> | ; <kbd>list<sub>n</sub>style<sup>†</sup></kbd> | ||
: | : CSS styles applied to specific <kbd>listN</kbd>. This has the highest priority and allows different lists to have unique styles. | ||
; <kbd>oddstyle</kbd> | ; <kbd>oddstyle</kbd>, <kbd>evenstyle</kbd> | ||
: | : Styles applied to odd/even-numbered lists. These override styles defined by <kbd>liststyle</kbd>. The default behavior is to add striped colors (white and gray) to odd/even rows to enhance readability. These settings should not be changed except in rare cases. | ||
; <kbd>evenodd</kbd> | ; <kbd>evenodd</kbd> | ||
: <code>[swap, even, odd]</code> | : <code>[swap, even, odd]</code> | ||
: | : Setting to <code>swap</code> reverses the odd/even styles of each list, useful for correcting mismatches caused by inserting sub-navigation boxes. | ||
: | : Setting to <code>even</code> or <code>odd</code> forces all lists to follow even-row or odd-row styles. | ||
; <kbd>abovestyle<sup>†</sup></kbd> | ; <kbd>abovestyle<sup>†</sup></kbd>, <kbd>belowstyle<sup>†</sup></kbd> | ||
: | : CSS styles applied to the top cell (specified by the <kbd>above</kbd> parameter) and the bottom cell (specified by the <kbd>below</kbd> parameter). Typically used for background color or text alignment: | ||
:* <code>abovestyle = background:#''nnnnnn'';</code> | :* <code>abovestyle = background:#''nnnnnn'';</code> | ||
:* <code>abovestyle = text-align:''left/center/right'';</code> | :* <code>abovestyle = text-align:''left/center/right'';</code> | ||
<!-- | <!-- The following parameters are currently unsupported in the Chinese template as of 2008-10-29 | ||
; <kbd>imagestyle<sup>†</sup></kbd> | ; <kbd>imagestyle<sup>†</sup></kbd> | ||
; <kbd>imageleftstyle<sup>†</sup></kbd> | ; <kbd>imageleftstyle<sup>†</sup></kbd> | ||
--> | --> | ||
===== | |||
===== Default Styles ===== | |||
The style settings listed here are the ones most frequently modified by editors using the navigation box. More complex styles have been excluded to keep this list simple. Most styles are set in [[MediaWiki:Common.css]]. | |||
<dl><dd><pre> | <dl><dd><pre> | ||
bodystyle = background:#fdfdfd; width:100%; vertical-align:middle; | bodystyle = background:#fdfdfd; width:100%; vertical-align:middle; | ||
Line 187: | Line 149: | ||
</pre></dd></dl> | </pre></dd></dl> | ||
Since <kbd>liststyle</kbd> and <kbd>oddstyle</kbd> are transparent, odd lists inherit the color of <kbd>bodystyle</kbd>, which defaults to #fdfdfd (white with a slight gray tint). Lists have <code>text-align:left;</code> if they have a group; otherwise, they are set to <code>text-align:center;</code>. As only <kbd>bodystyle</kbd> has a vertical alignment property, all other styles inherit its <code>vertical-align:middle;</code> setting. | |||
== | == Table Layout == | ||
A table generated by {{tl|Navbox}} '''without''' <kbd>image</kbd>, <kbd>above</kbd>, and <kbd>below</kbd> parameters (gray background added for demonstration purposes): | |||
{{Navbox | {{Navbox | ||
Line 201: | Line 163: | ||
|group2= {{{group2}}} | |group2= {{{group2}}} | ||
|list2 = {{{list2}}} | |list2 = {{{list2}}} | ||
|list3 = {{{list3}}} '' | |list3 = {{{list3}}} ''without {{{group3}}}'' | ||
|group4= {{{group4}}} | |group4= {{{group4}}} | ||
|list4 = {{{list4}}} | |list4 = {{{list4}}} | ||
}} | }} | ||
A table generated by {{tl|Navbox}} '''with''' <kbd>image</kbd>, <kbd>above</kbd>, and <kbd>below</kbd> parameters (gray background added for demonstration purposes): | |||
{{Navbox | {{Navbox | ||
Line 221: | Line 181: | ||
|group2= {{{group2}}} | |group2= {{{group2}}} | ||
|list2 = {{{list2}}} | |list2 = {{{list2}}} | ||
|list3 = {{{list3}}} '' | |list3 = {{{list3}}} ''without {{{group3}}}'' | ||
|group4= {{{group4}}} | |group4= {{{group4}}} | ||
|list4 = {{{list4}}} | |list4 = {{{list4}}} | ||
|below = {{{below}}} | |below = {{{below}}} | ||
}} | }} | ||
<includeonly> | <includeonly> | ||
Line 616: | Line 191: | ||
[[Category:Navigation templates]] | [[Category:Navigation templates]] | ||
[[Category:Formatting templates]] | [[Category:Formatting templates]] | ||
</includeonly><noinclude>[[Category:Template Documentation]]</noinclude> | </includeonly><noinclude>[[zh:Template:Navbox/doc]][[Category:Template Documentation]]</noinclude> |
Latest revision as of 19:37, 13 January 2025
This template allows for relatively convenient and quick summarization of similar types of entries to create a navigation template (referred to here as Category:Navbox templates).
This template is highly customizable and can be used in combination with {{Navbox subgroup}}, {{Navbox with columns}}, and {{Navbox with collapsible groups}}.
Common Parameters
- name
- The name of the template (the part after "Template:", not the title of the template), e.g., "Attributes".
- title
- The text in the title bar, e.g., "Attributes • List of attributes". It does not have to match
name
. - state
[mw-uncollapsed, mw-collapsed]
- The initial collapse state of the box.
- titlestyle, groupstyle, evenstyle
- CSS styles for the title bar, groups, and even-numbered lists (default light green), respectively, e.g.,
background:gray
. - above
- Content displayed above the group/list section.
- groupn
- The text on the left, appearing before listn (if groupn is omitted, listn starts at the left edge of the box).
- listn
- Text listing wiki links, typically separated by bullet points, e.g., [[A]] • [[B]] • ….
- below
- Optional text displayed below the group/list section.
Source code with common parameters, which can be copied for quick creation of a navigation template |
---|
Remove unused parameters; do not retain them unnecessarily. {{Navbox |name = {{subst:PAGENAME}} |title = |state = |titlestyle= background: |groupstyle= background: |evenstyle = background: |above = |group1= |list1 = [[]] • <!-- -->[[]] |group2= |list2 = [[]] • <!-- -->[[]] |group3= |list3 = [[]] • <!-- -->[[]] |group4= |list4 = [[]] • <!-- -->[[]] |group5= |list5 = [[]] • <!-- -->[[]] |group6= |list6 = [[]] • <!-- -->[[]] |below = }} |
Most other parameters for Navbox are not commonly used, so two simplified templates have been created for the most common parameters: {{Navbox family}} and {{Navbox family row}} ({{Links}}).
Examples of some commonly used parameters can be found under #Layout of the table and #Examples. Detailed explanations and complex constraints are provided in the #Parameter descriptions section below.
Parameter Descriptions
Template:FromOther
Below is a complete list of parameters for {{Navbox}}. In most cases, only the name
, title
, and list1
parameters are needed, though sub-navboxes may not require even these.
{{Navbox}} shares many common parameters with its sister templates {{Navbox with columns}} and {{Navbox with collapsible groups}} to enhance consistency and usability. Parameters marked with a "†" are applicable to all three main templates.
Configuration Parameters
- name†
- The name of the template. To ensure the "view • talk • edit" links work correctly on all pages using the template, this parameter needs to be set. You can use
{{subst:PAGENAME}}
as the value for this parameter as a shortcut. This parameter is required.
- state†
[mw-uncollapsed, mw-collapsed, plain, off]
- If set to
mw-collapsed
, the navbox will always appear collapsed by default. - If set to
plain
, the navbox will always be expanded without a "hide" link on the right, with the title centered (via padding to offset the "view • talk • edit" links). - If set to
off
, the navbox will always be expanded without a "hide" link, but no padding will be applied to center the title. This option is for advanced use; the "plain" option should suffice for most cases where the "show"/"hide" buttons need to be removed. - For any other value (e.g., "mw-uncollapsed"), the navbox will always appear expanded by default, with a "hide" button.
- If set to
Style Parameters
- style†
- Specifies CSS styles applied to the main body of the template. The bodystyle parameter achieves the same effect as this style parameter and can be used as a substitute. This option should be used with caution as it may cause visual inconsistencies. Examples:
style = background:#nnnnnn;
style = width:N [em/%/px or width:auto];
style = float:[left/right/none];
style = clear:[right/left/both/none];
- titlestyle†
- CSS styles applied to the title, often used to customize the background color of the navigation bar:
titlestyle = background:#nnnnnn;
titlestyle = background:name;
- groupstyle†
- CSS styles applied to all group cells. This option overrides any styles applied to the entire table. Examples:
groupstyle = background:#nnnnnn;
groupstyle = text-align:[left/center/right];
groupstyle = vertical-align:[top/middle/bottom];
- groupnstyle†
- CSS styles applied to specific groupN. This has the highest priority and allows different groups to have unique styles.
- liststyle†
- CSS styles applied to all list items. If listnstyle, oddstyle, or evenstyle parameters are specified, they take precedence over this parameter.
- listnstyle†
- CSS styles applied to specific listN. This has the highest priority and allows different lists to have unique styles.
- oddstyle, evenstyle
- Styles applied to odd/even-numbered lists. These override styles defined by liststyle. The default behavior is to add striped colors (white and gray) to odd/even rows to enhance readability. These settings should not be changed except in rare cases.
- evenodd
[swap, even, odd]
- Setting to
swap
reverses the odd/even styles of each list, useful for correcting mismatches caused by inserting sub-navigation boxes. - Setting to
even
orodd
forces all lists to follow even-row or odd-row styles.
- abovestyle†, belowstyle†
- CSS styles applied to the top cell (specified by the above parameter) and the bottom cell (specified by the below parameter). Typically used for background color or text alignment:
abovestyle = background:#nnnnnn;
abovestyle = text-align:left/center/right;
Default Styles
The style settings listed here are the ones most frequently modified by editors using the navigation box. More complex styles have been excluded to keep this list simple. Most styles are set in MediaWiki:Common.css.
bodystyle = background:#fdfdfd; width:100%; vertical-align:middle; titlestyle = background:#ccccff; padding-left:1em; padding-right:1em; text-align:center; abovestyle = background:#ddddff; padding-left:1em; padding-right:1em; text-align:center; belowstyle = background:#ddddff; padding-left:1em; padding-right:1em; text-align:center; groupstyle = background:#ddddff; padding-left:1em; padding-right:1em; text-align:right; liststyle = background:transparent; text-align:left/center; oddstyle = background:transparent; evenstyle = background:#f7f7f7;
Since liststyle and oddstyle are transparent, odd lists inherit the color of bodystyle, which defaults to #fdfdfd (white with a slight gray tint). Lists have text-align:left;
if they have a group; otherwise, they are set to text-align:center;
. As only bodystyle has a vertical alignment property, all other styles inherit its vertical-align:middle;
setting.
Table Layout
A table generated by {{Navbox}} without image, above, and below parameters (gray background added for demonstration purposes):
|
A table generated by {{Navbox}} with image, above, and below parameters (gray background added for demonstration purposes):
|