Template:Sandbox/User:The Gaffer/Templates/Infobox Switch
mw.loader.load('ext.gadget.switch-infobox')
Script error: The function "infobox" does not exist.
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
mw.loader.load('ext.gadget.switch-infobox') Script error: The function "infobox" does not exist.
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
mw.loader.load('ext.gadget.switch-infobox') Script error: The function "infobox" does not exist.
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.
|