Please note that some information on this wiki is still based on the demo version.
If you notice any errors, feel free to correct them.

Template:Navbox/doc: Difference between revisions

From Super Fantasy Kingdom Official Wiki
wgg>Cadaei
taken from https://ark.wiki.gg/wiki/Template:Navbox/doc
 
wgg>Cadaei
from https://support.wiki.gg/wiki/Template:Navbox/doc
Line 1: Line 1:
{{doc/start}}
{{no direct use}}
== Usage ==
{{UsesLua|Navbox}}
Please remove the parameters that are left blank.
This template is designed to set up navigational templates relatively quickly with one or more lists of links. We highly recommend using this template for standardizing navigational templates and ease of use, especially for mobile devices.


<pre style="overflow: auto;">{{Navbox
See [[support:RANGER navboxes|the support wiki]] for more information, including installation steps and further examples.
| name      = {{subst:PAGENAME}}{{subst:void|Don't change anything on this line. It will change itself when you save.}}
| title      =
| listclass  = hlist
| state      = {{{state|}}}


| above      =  
== Basic example ==
| image      =
The following example demonstrates the core functionality of this template: the title text, one standard link group, and one link group that contains two sub-groups. The rows are striped for easier readability.


| group1    =  
{{Navbox
| list1      =  
| title = Items
| striped = even


| group2    =  
| group1 = Consumables
| list2      =  
| list1 =
<!-- ... -->
* Health Potion
| group20    =
* Mana Potion
| list20    =


| below      =  
| group2 = Weapons
 
| group2.1 = Swords
| list2.1 =
* Wooden Sword
* Rusted Sword
* Steel Sword
 
| group2.2 = Bows
| list2.2 =
* Shortbow
* Crossbow
* Longbow
}}
}}
</pre>
<syntaxhighlight lang="wikitext" style="overflow: auto;">
{{Navbox
| title = Items
| striped = even
 
| group1 = Consumables
| list1 =
* Health Potion
* Mana Potion
 
| group2 = Weapons


== Parameter list ==
| group2.1 = Swords
{{Navbox
| list2.1 =
| name  = Navbox/doc
* Wooden Sword
| state  = uncollapsed
* Rusted Sword
| title  = {{{title}}}
* Steel Sword
| above  = {{{above}}}
 
| image  = {{{image}}}
| group2.2 = Bows
| group1 = {{{group1}}}
| list2.2 =
| list1  = {{{list1}}}
* Shortbow
| group2 = {{{group2}}}
* Crossbow
| list2 = {{{list2}}}
* Longbow
| list3  = {{{list3}}} ''without {{{group3}}}''
| group4 = {{{group4}}}
| list4  = {{{list4}}}
| below  = {{{below}}}
}}
}}
</syntaxhighlight>
== Parameters ==
=== Main ===
The following parameters modify the navbox as a whole.
{| class="wikitable"
! Parameter
! Description
|-
! <code>title</code>
| Text that appears at the top of the navbox.
|-
! <code>state</code><br><code>collapsible</code>
| Controls if a navbox should be expanded or collapsed when the page loads. This only affects the whole navbox; if [[#Sections|sections]] are used, they are treated differently.
* <code>expanded</code> ('''default''') - the navbox will start open and readers can collapse it.
* <code>collapsed</code> - the navbox will start closed and readers can expand it.
* <code>off</code>, <code>no</code>, or <code>plain</code> - the navbox will start open and cannot be collapsed.
Advanced users can modify this on a page-by-page basis; see [[#Snippets|§ Snippets]].
|-
! <code>editlinks</code>
| Controls if an edit icon should be displayed at the top-left of the navbox, making it easier for users to interact with the template itself.
* unset ('''default''') - displays the edit icon
* <code>off</code> or <code>no</code> - hides the edit icon
|-
! <code>above</code>
| Text that appears above all list groups, directly below the title.
|-
! <code>below</code>
| Text that appears below all list groups, at the bottom of the navbox.
|-
! <code>striped</code><br><code>evenodd</code>
| Controls if the navbox rows should have zebra striping on even or odd rows, making it easier for users to distinguish two rows apart from each other. If [[#Sections|sections]] are used, each section resets the even/odd counter.
*unset ('''default''') - all rows have the same background
*<code>y</code>, <code>yes</code>, <code>on</code>, <code>striped</code>, or <code>even</code> - even-numbered rows are highlighted
*<code>swap</code> or <code>odd</code> - odd-numbered rows are highlighted
|}
=== Sections ===
The following parameters define sections within the navbox with their own titles.
{| class="wikitable"
! Parameter
! Description
|-
! <code>header''n''</code>
| Text that appears at the top of the section, where ''n'' is any positive integer. If the value is set to two or more <code>-</code> (e.g. <code>--</code>, <code>-----</code>, etc.) the new section will have no header bar and cannot be collapsed.
All groups and lists that are ''n'' or higher will appear in this section unless there is a higher <code>header''n''</code> later in the template. For example, if a navbox defines <code>header1</code> and <code>header4</code>, the first section will include <code>list1</code>, <code>list2</code>, and <code>list3</code> (and any of their sub-lists), while the second section will include all remaining lists starting at <code>list4</code> and their sub-lists.
|-
! <code>header_state</code><br><code>state''n''</code>
| <code>header_state</code> controls if all sections, by default, should be expanded or collapsed when the page loads.
<code>state''n''</code> overrides <code>header_state</code> for the specific section defined by <code>header''n''</code> (where ''n'' is a matching integer).
* <code>expanded</code> ('''default''') - the section will start open and readers can collapse it.
* <code>collapsed</code> - the section will start closed and readers can expand it.
* <code>off</code> or <code>plain</code> - the section will start open and cannot be collapsed.
Advanced users can modify these on a page-by-page basis; see [[#Snippets|§ Snippets]].
Both parameters have no effect on sections with headers set to two or more <code>-</code>, which are always expanded and cannot be collapsed.
|}
=== List groups ===
The following parameters define the list groups.
{| class="wikitable"
! Parameter
! Description
|-
! <code>group''n''</code>
| Text label for a list, which appears on the left on desktop or at the top on mobile, where ''n'' is any positive integer.
This parameter is optional; if a <code>list''n''</code> does not have a matching <code>group''n''</code>, the list will take the full width on desktop.
|-
! <code>list''n''</code>
| A wikitext list, where ''n'' is any positive integer.
|-
! <code>group''n''.''x''</code><br><code>group''n''.''x''.''y''</code><br>etc.
| Text label for sub-lists that appear under <code>group''n''</code>, <code>group''n''.''x''</code>, etc.
|-
! <code>list''n''.''x''</code><br><code>list''n''.''x''.''y''</code><br>etc.
| Wikitext sub-lists.
|}
=== Styling ===
The following parameters add inline styling or your custom CSS classes to specific elements of the navbox.


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.
To assist with text alignment, three default classes are available: <code>align-left</code>, <code>align-center</code>, and <code>align-right</code>.


Notice "group1" (etc.) is optional, as are sections named "above/below".
In addition, two more default classes
{{clear}}
The basic and most common parameters are as follows (see [[#Parameter descriptions|below]] for the full list):


: <code>name</code> – the name of the template.
{| class="wikitable"
: <code>title</code> – text in the title bar, such as: <nowiki>[[Widget stuff]]</nowiki>.
! Parameter
: <code>listclass</code> – a CSS class for the list cells, usually <code>hlist</code> for horizontal lists. Alternatively, use bodyclass for the whole box.
! Description
: <code>state</code> – controls when a navbox is expanded or collapsed.
|-
: <code>titlestyle</code> – a CSS style for the title-bar, such as: <code>background: gray;</code>
! <code>navbox_style</code><br><code>navbox_class</code>
: <code>groupstyle</code> – a CSS style for the group-cells, such as: <code>background: #eee;</code>
| Modifies the parent navbox element; <code>class</code> can be used as a shorthand for <code>navbox_class</code>
: <code>above</code> – text to appear above the group/list section (could be a list of overall wikilinks).
: <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>[[File:</nowiki><var>XX</var><nowiki>.jpg|80px|link=|alt=]]</nowiki></code>.
: <code>imageleft</code> – an optional left-side image (code the same as the "image" parameter).
: <code>group<sub>n</sub></code> – the left-side text before list-n (if group-n omitted, list-n starts at left of box).
: <code>list<sub>n</sub></code> – text listing wikilinks using a [[wikipedia:Help:Lists|wikilist]] format.
: <code>below</code> – optional text to appear below the group/list section.


== Parameter descriptions ==
Two default classes are available:
The following is a complete list of parameters for using {{tlx|Navbox}}. In most cases, the only required parameters are <code>name</code>, <code>title</code>, and <code>list1</code>.
*<code>pill</code> changes the links to pill-styled rather than dot-separated
*<code>pill-mobile</code> only changes the links to pill-styled on mobile devices
|-
! <code>title_style</code><br><code>title_class</code>
| Modifies the title bar
|-
! <code>above_style</code><br><code>above_class</code>
| Modifies the <code>above</code> text row
|-
! <code>below_style</code><br><code>below_class</code>
| Modifies the <code>below</code> text row
|-
! <code>header_style</code><br><code>header_class</code>
| Modifies all section headers (''not'' the title bar)
|-
! <code>header''n''_style</code><br><code>header''n''_class</code>
| Modifies the specific section header ''n''
|-
! <code>section''n''_style</code><br><code>section''n''_class</code>
| Modifies the container holding the section defined by a matching <code>header''n''</code>
|-
! <code>group_style</code><br><code>group_class</code>
| Modifies all base groups (<code>group''n''</code>), but ''not'' any subgroups (<code>group''n''.''x''</code>, etc.)
|-
! <code>subgroup_style</code><br><code>subgroup_class</code>
| Modifies all subgroups at all levels (<code>group''n''.''x''</code>, <code>group''n''.''x''.''y''</code>, etc.)
|-
! <code>group''A''_style</code><br><code>group''A''_class</code>
| Modifies the specific group ''A'', where ''A'' is any ''n'', ''n''.''x'', ''n''.''x''.''y'', etc.
|-
! <code>list_style</code><br><code>list_class</code>
| Modifies all lists. Note, in this context, "list" refers to the container of a <code>list''n''</code> parameter, not a <code>ul</code> or <code>ol</code> element inside the parameter
|-
! <code>list''A''_style</code><br><code>list''A''_class</code>
| Modifies the specific list ''A'', where ''A'' is any ''n'', ''n''.''x'', ''n''.''x''.''y'', etc.
|}


=== Setup parameters ===
<noinclude>[[Category:Template documentation]]</noinclude>
:; ''name''
:: The name of the template, which is needed for the "V&nbsp;• T&nbsp;• E" ("View&nbsp;• Talk&nbsp;• 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, and the <code>navbar</code> parameter is not used to disable the navbar.
:; ''state'' <span style="font-weight:normal;">[<code>autocollapse, collapsed, expanded, plain, off</code>]</span>
:* 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.
:* If set to <code>collapsed</code>, the navbox will always start out in a collapsed state.
:* If set to <code>expanded</code>, the navbox will always start out in an expanded 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&nbsp;• T&nbsp;• 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.
: To show the box when standalone (non-included) but then auto-hide contents when in an article, put "expanded" inside <code>&lt;noinclude|&gt;</code>...<code>&lt;/noinclude|&gt;</code> 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:
:: <code><nowiki>| state =&nbsp;</nowiki></code><code>&lt;noinclude|&gt;</code>expanded<code>&lt;/noinclude|&gt;</code>
: 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:
:: <code><nowiki>| state = {{{state<includeonly>|your_desired_initial_state</includeonly>}}}</nowiki></code>
:* The <code>&lt;includeonly&gt;</code><code>|</code> will make the template expanded when viewing the template page by itself.
:; ''navbar''
:: If set to <code>plain</code>, the <span style="font-size: 88%;">V&nbsp;• T&nbsp;• E</span> 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 <span style="font-size: 88%;">V&nbsp;• T&nbsp;• E</span> 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''
{{doc/end}}

Revision as of 18:37, 12 December 2024

Don't call this template directly from any content page!

This template is intended to be used inside of another template. Then that template in turn may be used on content pages.

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: {{#arraymap:Navbox|,|%s|%s}}.

This template is designed to set up navigational templates relatively quickly with one or more lists of links. We highly recommend using this template for standardizing navigational templates and ease of use, especially for mobile devices.

See the support wiki for more information, including installation steps and further examples.

Basic example

The following example demonstrates the core functionality of this template: the title text, one standard link group, and one link group that contains two sub-groups. The rows are striped for easier readability.

<syntaxhighlight lang="wikitext" style="overflow: auto;">

</syntaxhighlight>

Parameters

Main

The following parameters modify the navbox as a whole.

Parameter Description
title Text that appears at the top of the navbox.
state
collapsible
Controls if a navbox should be expanded or collapsed when the page loads. This only affects the whole navbox; if sections are used, they are treated differently.
  • expanded (default) - the navbox will start open and readers can collapse it.
  • collapsed - the navbox will start closed and readers can expand it.
  • off, no, or plain - the navbox will start open and cannot be collapsed.

Advanced users can modify this on a page-by-page basis; see § Snippets.

editlinks Controls if an edit icon should be displayed at the top-left of the navbox, making it easier for users to interact with the template itself.
  • unset (default) - displays the edit icon
  • off or no - hides the edit icon
above Text that appears above all list groups, directly below the title.
below Text that appears below all list groups, at the bottom of the navbox.
striped
evenodd
Controls if the navbox rows should have zebra striping on even or odd rows, making it easier for users to distinguish two rows apart from each other. If sections are used, each section resets the even/odd counter.
  • unset (default) - all rows have the same background
  • y, yes, on, striped, or even - even-numbered rows are highlighted
  • swap or odd - odd-numbered rows are highlighted

Sections

The following parameters define sections within the navbox with their own titles.

Parameter Description
headern Text that appears at the top of the section, where n is any positive integer. If the value is set to two or more - (e.g. --, -----, etc.) the new section will have no header bar and cannot be collapsed.

All groups and lists that are n or higher will appear in this section unless there is a higher headern later in the template. For example, if a navbox defines header1 and header4, the first section will include list1, list2, and list3 (and any of their sub-lists), while the second section will include all remaining lists starting at list4 and their sub-lists.

header_state
staten
header_state controls if all sections, by default, should be expanded or collapsed when the page loads.

staten overrides header_state for the specific section defined by headern (where n is a matching integer).

  • expanded (default) - the section will start open and readers can collapse it.
  • collapsed - the section will start closed and readers can expand it.
  • off or plain - the section will start open and cannot be collapsed.

Advanced users can modify these on a page-by-page basis; see § Snippets.

Both parameters have no effect on sections with headers set to two or more -, which are always expanded and cannot be collapsed.

List groups

The following parameters define the list groups.

Parameter Description
groupn Text label for a list, which appears on the left on desktop or at the top on mobile, where n is any positive integer.

This parameter is optional; if a listn does not have a matching groupn, the list will take the full width on desktop.

listn A wikitext list, where n is any positive integer.
groupn.x
groupn.x.y
etc.
Text label for sub-lists that appear under groupn, groupn.x, etc.
listn.x
listn.x.y
etc.
Wikitext sub-lists.

Styling

The following parameters add inline styling or your custom CSS classes to specific elements of the navbox.

To assist with text alignment, three default classes are available: align-left, align-center, and align-right.

In addition, two more default classes

Parameter Description
navbox_style
navbox_class
Modifies the parent navbox element; class can be used as a shorthand for navbox_class

Two default classes are available:

  • pill changes the links to pill-styled rather than dot-separated
  • pill-mobile only changes the links to pill-styled on mobile devices
title_style
title_class
Modifies the title bar
above_style
above_class
Modifies the above text row
below_style
below_class
Modifies the below text row
header_style
header_class
Modifies all section headers (not the title bar)
headern_style
headern_class
Modifies the specific section header n
sectionn_style
sectionn_class
Modifies the container holding the section defined by a matching headern
group_style
group_class
Modifies all base groups (groupn), but not any subgroups (groupn.x, etc.)
subgroup_style
subgroup_class
Modifies all subgroups at all levels (groupn.x, groupn.x.y, etc.)
groupA_style
groupA_class
Modifies the specific group A, where A is any n, n.x, n.x.y, etc.
list_style
list_class
Modifies all lists. Note, in this context, "list" refers to the container of a listn parameter, not a ul or ol element inside the parameter
listA_style
listA_class
Modifies the specific list A, where A is any n, n.x, n.x.y, etc.