Template:Sandbox/User:The Gaffer/Templates/Infobox Switch: Difference between revisions

From Brighter Shores Wiki
Jump to navigation Jump to search
Content added Content deleted
(Created page with "<includeonly>{{#invoke:Infobox Switch|main}}</includeonly><noinclude>{{/doc}}</noinclude>")
 
No edit summary
Line 1: Line 1:
<includeonly>{{#invoke:Infobox Switch|main}}</includeonly><noinclude>{{/doc}}</noinclude>
<includeonly>{{#invoke:Modules:Sandbox/User:The Gaffer/Modules/Infobox Switch|main}}</includeonly><noinclude>{{/doc}}</noinclude>

Revision as of 11:27, 12 November 2024

Template documentation
Template:Sandbox/User:The Gaffer/Templates/Infobox Switch invokes function main in Module:Modules: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

Script error: No such module "Modules:Sandbox/User:The Gaffer/Modules/Infobox Switch".

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

Script error: No such module "Modules:Sandbox/User:The Gaffer/Modules/Infobox Switch".

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