Template:Sandbox/User:The Gaffer/Templates/Infobox Switch

From Brighter Shores Wiki
Jump to navigation Jump to search
<tbody></tbody>
Template documentation
Template:Sandbox/User:The Gaffer/Templates/Infobox Switch invokes function infobox_switch in Module:Sandbox/User:The Gaffer/Modules/Infobox Switch using Lua.

Template:Infobox Switch is used to display infoboxes of the same type on a single page. It is typically used to separate versions of the subject with different conditions (for example, the different variations of weapon quality).

After the insertion of the template, there will be different buttons stating the possible conditions of that page. When clicked on different conditions, the page will display different information.

Note that switch infoboxes can have unintended interactions with other switch infoboxes, or with other infoboxes that contain multiple versions. You can specify your own switch_id's to mitigate this interaction (see #Specifying switch IDs below).

Usage

{{Switch infobox
|text1 = Name of condition 1
|item1 = Type information here which is shown in condition 1
|text2 = Name of condition 2
|item2 = Type information here which is shown in condition 2
|text3 = Name of condition 3
|item3 = Type information here which is shown in condition 3
}}

produces

<button class="button" data-switch-index="1" data-switch-anchor="#section1">Name of condition 1</button><button class="button" data-switch-index="2" data-switch-anchor="#section2">Name of condition 2</button><button class="button" data-switch-index="3" data-switch-anchor="#section3">Name of condition 3</button>
<tbody></tbody>
Type information here which is shown in condition 1
Type information here which is shown in condition 2
Type information here which is shown in condition 3
Type information here which is shown in condition 1


Specifying switch IDs

By default, each switch item uses an ID of 1, 2, 3, etc. Because all switch infoboxes and multi-version infoboxes use the same numerical ID by default, they all switch at the same time, which is often not intended. To avoid this issue, you can manually specify the ID for each item with the switch_id#, where # is the item number. These switch IDs can be specified to avoid conflicts with other switch infoboxes or multi-version infoboxes. The rules for specifying switch_id are:

  • switch_id can be text, including most special characters (although it's probably a good idea to keep it simple)
  • switch_id must not contain double-quotes (")
  • Do NOT use the same switch_id for multiple items in the same switch infobox. This causes both items to be shown when clicked and duplicates the switch buttons.

Note that if using switch_id's on a page containing a Template:Synced switch, you will probably want to specify nodefault=y in the sync switch. See the documentation on Template:Synced switch#No default switching and Template:Synced switch#Switch IDs for more detail.

Example usage:

{{Switch infobox
|text1 = 1: My switch ID is alt1
|switch_id1 = alt1
|item1 = Item 1: Note that this does not interact with the other example on this page.
|text2 = 2: My switch ID is alt2
|switch_id2 = alt2
|item2 = Item2: Note that this does not interact with the other example on this page.
}}

produces

<button class="button" data-switch-index="1" data-switch-anchor="#section1">1: My switch ID is alt1</button><button class="button" data-switch-index="2" data-switch-anchor="#section2">2: My switch ID is alt2</button>
<tbody></tbody>
Item 1: Note that this does not interact with the other example on this page.
Item2: Note that this does not interact with the other example on this page.
Item 1: Note that this does not interact with the other example on this page.


Quick copy

Note: The template is not limited to 2 conditions only. Editors can add more conditions if available.

{{Switch infobox
|text1 = 
|item1 = 
|text2 = 
|item2 = 
}}

See also

Template data

Show/hide template's data

The following information is used by extensions and applications, such as VisualEditor, to help users implement this template onto pages. Please ensure that it is up-to-date.

Used to separate different information on a specific page with different conditions.

Template parameters[Edit template data]

This template has custom formatting.

ParameterDescriptionTypeStatus
Title #1text1

Name of condition

Linerequired
ID #1switch_id1

Switch ID for condition #1; see full template docs

Lineoptional
Item #1item1

Information (e.g. an infobox) shown for the corresponding condition

Contentrequired
Title #2text2

Name of condition

Linerequired
ID #2switch_id2

Switch ID for condition #2; see full template docs

Lineoptional
Item #2item2

Information (e.g. an infobox) shown for the corresponding condition

Contentrequired
Title #3text3

Name of condition

Lineoptional
ID #3switch_id3

Switch ID for condition #3; see full template docs

Lineoptional
Item #3item3

Information (e.g. an infobox) shown for the corresponding condition

Contentoptional
Title #4text4

Name of condition

Lineoptional
ID #4switch_id4

Switch ID for condition #4; see full template docs

Lineoptional
Item #4item4

Information (e.g. an infobox) shown for the corresponding condition

Contentoptional
Title #5text5

Name of condition

Lineoptional
ID #5switch_id5

Switch ID for condition #5; see full template docs

Lineoptional
Item #5item5

Information (e.g. an infobox) shown for the corresponding condition

Contentoptional
Title #6text6

Name of condition

Lineoptional
ID #6switch_id6

Switch ID for condition #6; see full template docs

Lineoptional
Item #6item6

Information (e.g. an infobox) shown for the corresponding condition

Contentoptional
Title #7text7

Name of condition

Lineoptional
ID #7switch_id7

Switch ID for condition #7; see full template docs

Lineoptional
Item #7item7

Information (e.g. an infobox) shown for the corresponding condition

Contentoptional
Title #8text8

Name of condition

Lineoptional
ID #8switch_id8

Switch ID for condition #8; see full template docs

Lineoptional
Item #8item8

Information (e.g. an infobox) shown for the corresponding condition

Contentoptional
Title #9text9

Name of condition

Lineoptional
ID #9switch_id9

Switch ID for condition #9; see full template docs

Lineoptional
Item #9item9

Information (e.g. an infobox) shown for the corresponding condition

Contentoptional
Title #10text10

Name of condition

Lineoptional
ID #10switch_id10

Switch ID for condition #10; see full template docs

Lineoptional
Item #10item10

Information (e.g. an infobox) shown for the corresponding condition

Contentoptional