Difference between revisions of "Template:Navbox"

From Stoneshard wiki
Jump to navigation Jump to search
old>Maintenance script-gpuser
(Automated Import)
 
m (4 revisions imported)
 
(3 intermediate revisions by 2 users not shown)
Line 7: Line 7:


--><table cellspacing="0" class="nowraplinks {{#if:{{{title|}}}|{{#switch:{{{state|}}}|plain|off=|<!--
--><table cellspacing="0" class="nowraplinks {{#if:{{{title|}}}|{{#switch:{{{state|}}}|plain|off=|<!--
  -->#default=mw-collapsible {{#if:{{{state|}}}|{{{state}}}|mw-collapsed}}}}}} {{#switch:{{{border|{{{1|}}}}}}|<!--
  -->#default=mw-collapsible {{#if:{{{state|}}}|{{{state}}}|<!--CHECK IF PAGE TITLE = 2ND PARAM, BECOME EXPANDED-->{{#ifeq:{{{expand|}}}|{{{title|}}}|expanded|mw-collapsed}}<!--END EXPANDED CHECK-->}}}}}} {{#switch:{{{border|{{{1|}}}}}}|<!--
  -->subgroup|child|none=navbox-subgroup" style="width:100%;{{{bodystyle|}}};{{{style|}}}|<!--
  -->subgroup|child|none=navbox-subgroup {{{bodyclass|}}}" style="width:100%;{{{bodystyle|}}};{{{style|}}}|<!--
  -->#default=" style="width:100%;background:transparent;color:inherit}};{{{innerstyle|}}};" data-expandtext="show" data-collapsetext="hide"><!--
  -->#default=" style="width:100%;background:transparent;color:inherit}};{{{innerstyle|}}};" data-expandtext="show" data-collapsetext="hide"><!--


Line 255: Line 255:


--></table>{{#switch:{{{border|{{{1|}}}}}}|subgroup|child=<div>|none=|#default=</td></tr></table>}}
--></table>{{#switch:{{{border|{{{1|}}}}}}|subgroup|child=<div>|none=|#default=</td></tr></table>}}
<noinclude>{{doc}}[[Category:Navigation templates]]</noinclude>
<noinclude>{{doc}}[[Category:Navigation templates|*]]</noinclude>

Latest revision as of 20:45, 21 November 2021

Template-info.png Documentation

Usage

Please remove the parameters that are left blank. Don't change anything on the line | name = {{subst:PAGENAME}}. It will change itself when you save.

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

| above      =
| image      =

| group1     =
| list1      =

| group2     =
| list2      =
<!-- ... -->
| group20    =
| list20     =

| 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]].
listclass – a CSS class for the list cells, usually hlist for horizontal lists. Alternatively, use bodyclass for the whole box.
state – controls when a navbox is expanded or collapsed.
titlestyle – a CSS style for the title-bar, such as: background: gray;
groupstyle – a CSS style for the group-cells, such as: background: #eee;
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.
expand – a custom parameter for Stoneshard Wiki. Allows you to expand Navboxes or Navbox subgroups on a per-page basis.

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. For the technically minded, see MediaWiki:Hydradark.js.
  • 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.
border
See section below 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 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 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 ... }}
expand
A custom parameter for Stoneshard Wiki. By default, when any title is specified and state isn't set to expanded/plain/off, the navbox automatically starts in collapsed state. The expand parameter allows you to select one specific navbox subgroup to start in expanded state. Expand parameter only works if you also specified the title and if state isn't set to expanded/plain/off.
Expected use is with multiple Navbox subgroups. The expand parameter is compared with the title parameter. If they match, the corresponding navbox subgroup starts expanded instead of collapsed. Used on {{Navigation}}.