Template:Navbox generic/doc

出自維基百科,自由嘅百科全書


This template allows a navigational template to be set up relatively quickly by supplying it one or more lists of links.

Blank template[編輯]

{{Navbox generic
|name       = {{subst:PAGENAME}}
|state      = 
|titlestyle = 
|title      = 
|image      = 
|bodystyle  = <!-- (or "style =" if no other style parameters used) -->
|groupstyle = 
|liststyle  = 
|oddstyle   = 
|evenstyle  = 

|abovestyle = 
|above = 

|group1 = 
|list1  = 

|group2 = 
|list2  = 

 ...

|group20 = 
|list20  = 

|belowstyle = 
|below = 
}}

Parameters[編輯]

Deprecated (but still functional) parameter names given in parentheses before each description.

Mandatory[編輯]

name
(or templateName) 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 {{subst:PAGENAME}} for this value as a shortcut.
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.
The background color defaults to #ccf (truncated form of #ccccff), but can be changed via the titlestyle parameter (see below).
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> (see #Example with code). 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).
The background color of the list items (and the entire table) defaults to #f9f9f9, but can be changed via the bodystyle, oddstyle and/or evenstyle parameters (see below).

Optional[編輯]

Cells[編輯]

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.
The background color defaults to #ddf (truncated form of #ddddff), but can be changed via the groupstyle parameter (see below).
image
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, i.e.
[[Image:Example.jpg|100px]]
In a template where the body (the groups and/or lists) does not extend all the way to the right side, the image will shift away from the right edge of the template. This can be avoided by using the right parameter within the image wikicode, i.e.
[[Image:Example.jpg|80px|right]]
above
(or top) 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.
below
(or bottom) 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 listn parameter without a groupn parameter. For an example of the below parameter in use, see {{Lists of the provinces and territories of Canada}}.

Styles[編輯]

titlestyle
(or title_style) CSS styles to apply to title, most often the titlebar's background color:
titlestyle = background:#nnnnnn;
titlestyle = background:name;
bodystyle or style
Specifies CSS styles to apply to the template body. The shorter name style may be used when no other style parameters are specified. This option should be used sparingly as it can lead to visual inconsistencies. Examples:
background:#nnnnnn;
text-align:[right/center/left/justified];
width:N [em/%/px or width:auto];
float:[left/right/none];
clear:[right/left/both/none];
groupstyle
(or group_style, group-style) CSS styles to apply to the groupN cells. This option overrides any styles that are applied to the entire table. Examples:
background:#nnnnnn;
text-align:[left/center/right];
vertical-align:[top/middle/bottom];
white-space:nowrap;
liststyle
CSS styles to apply to all lists. Overruled by the oddstyle and evenstyle parameters (if specified) below.
oddstyle
evenstyle
(or odd-style, even-style) CSS styles to apply to the odd-numbered list items (list1, list3, etc) or even-numbered list items (list2, list4, etc), respectively. Typically used to set background color (background:#nnnnnn;) in order to achieve an alternating background color between odd and even-numbered lists; see {{Turkey-related topics}} for an example.
abovestyle
belowstyle
(or above_style, top-style; below_style, bottom-style) 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:
background:#nnnnnn;
text-align:[left/center/right];

Other[編輯]

state
Defaults to autocollapse. If set to collapsed, the navbox will always start out in a collapsed state. If set to blank or anything other than autocollapse or collapsed, the navbox will always start out in an expanded state. A navbox with autocollapse will start out collapsed if there are two or more tables on the same page that use collapsible. For the technically minded, see MediaWiki:Common.js.
Often times, editors will want a default initial state for a nav box, 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>}}}
Example: {{peso}} with autocollapse as the default initial state. Bolivian peso transcludes it and has only one nav box. So the peso nav box shows. Chilean peso has two nav boxes. So the peso nav box collapses.
Example: {{Historical currencies of Hungary}} with expanded as the default initial state. All transcluding articles shows the content by default, unless there were an hypothetical article that specifies state = collapsed when transcluding.
The <includeonly>| will make the template expanded when viewing the template page by itself.


Layout of table[編輯]

Example with code[編輯]

{{Navbox generic
|name      = {{subst:PAGENAME}}
|state     = {{{state|uncollapsed}}}
|title     = [[Wikipedia:Navigational templates|Navigational templates]]
|bodystyle = width:50%;

|group1    = Physics
|list1     = [[Template:Cosmology|Cosmology]]{{·}} [[Template:General relativity|Relativity]]{{·}}
[[Template:String-theory|String theory]]

|group2    = Continents
|list2     = <div>
[[Template:Africafooter|Africa]]{{·}}
[[Template:Asiafooter|Asia]]{{·}}
[[Template:Europefooter|Europe]]
</div>

|list3     = [[Template:National parks of Argentina|Argentinian National Parks]]
}}

Additional examples[編輯]

No image[編輯]

With image[編輯]

With image and styles[編輯]

See also[編輯]

導航模比較
摺得埋 頂欄色 分組 主體樣式
參數
{{Navbox}} 摺得埋 navbox 主體左/右邊
{{Navbox with collapsible groups}} 摺得埋 navbox 主體左/右邊
同埋 每個表左/右邊
{{Navbox with columns}} 摺得埋 navbox 欄左/右邊