Template:Versions2

From Warcraft Watch Secrets
Jump to navigation Jump to search

Versions2 enables some background magic (via the UsingData extension) to show and switch between alternate versions of items or spells (Raid Finder versus Normal versus Heroic, or ranks of spells) in a way that falls back sanely for readers without javascript enabled.

Editors are advised against using this template directly:

  • For common raid items, use {{Versions/Item}}, which automatically includes Heroic, Raid Finder, Flexible, Thunderforged, Elite, Warforged, and other similar versions as appropriate.
  • For items with Alliance/Horde versions, use {{Versions/AH}}

Template arguments

Name Description
Required
|basename= The default version displayed. Defaults to "Base". Typically |basename=Normal
|basepos= The index of the default location. Defaults to 0. Typically |basepos=1
|tpl= The template used to display the tooltip. Typically |tpl=itemtip
Unnamed parameters
|1= (to |20=) Alternate versions of the first fully-defined option
External links
|elinks-tpl= Use this template for external links. Passed to {{elinks-versions}}. Typically |elinks-tpl=item
|elinks-arg= Use this argument in the external link. Typically |elinks-arg=itemid
|elinks-bonus= For items with the same itemid but different bonuses. Typically |elinks-bonus=bonusid

Example

For a fully-fledged, live example, see Regail's Crackling Dagger. A simplified example is described and implemented here.

There are three versions of an item: Blandsauce, Awesomesauce, and Weaksauce. Define the normal ("blandsauce") version first, followed by the others:

{{#data:itemtip
|name=Example item
|ilvl=200
|quality=Epic
|slot=Trinket
|itemid=12345
}}{{#data:#Weaksauce
|name=Example item
|tag=Weaksauce
|ilvl=1
|quality=Poor
|slot=Trinket
|itemid=12346
}}{{#data:#Awesomesauce
|name=Example item
|tag=Awesomesauce
|ilvl=400
|quality=Legendary
|slot=Trinket
|itemid=12347
}}

Note that subsequent calls to {{#data: do not include the display template ({{itemtip}} in this case). This way they are not displayed at the top of the page, but they are defined. They do, however, define a data fragment (with the name of the fragment specified after the second #). Any additional content such as source, description, screenshots, etc. should follow the data definitions. Near the end of the page, but after the "Patches changes" section and before the "External links" section (if not using the built-in generated external links), add a second-level "Other versions" section, followed by a call to this template:

==Other versions==
{{Versions2|Weaksauce|Awesomesauce|basename=Blandsauce|basepos=1|tpl=itemtip}}

Finally, add any closing content, such as notes about patch changes, external links to other sites, and any categorization required.

Explanation of parameters

Versions2 takes up to eleven non-named parameters, which, including the base version of the item/spell, can display up to twelve different versions of a tooltip on the page. The parameters must be listed in the order in which they are to be displayed, and must match a data fragment provided by the page. Empty parameters are ignored, and may appear before non-empty parameters, so {{versions2|||Heroic||}} and {{versions2|Heroic}} are equivalent.

The base version of an item can have its name redefined (if "Base" is inappropriate), and its position among the other versions can be changed. Traditionally, multiple versions of an item are ordered by item level in ascending order, so the "Normal" version of an item would be listed after the "Raid Finder" version. This is accomplished with |basename=Normal|basepos=1. |basename= redefines the name from "Base" to "Normal", and assigns it the 1st position in a 0-based list.

Finally, a display template must be specified. Most uses of Versions2 are for items, so use |tpl=itemtip.

Version2 also enables a fallback mode, displaying the alternate versions of the tooltip as third-level (===Weaksauce===) sections near the end of the page for readers with javascript disabled. This is normally hidden by sitewide javascript and instead displayed/selected via the tabs added to the top of the page. To manually suppress this alternate-version hiding javascript for testing purposes, add "#!noversions" to the URL and open it in a new tab. (e.g. https://secrets.warcraftwatch.com/wiki/Template:Versions2/doc#!noversions)

Versions2 also can generate external links, including the bonus ids of items if necessary. For items, include the parameters |elinks-tpl=item|elinks-arg=itemid|elinks-bonus=bonusid in the template call. {{Versions/Item}} already does this.

Other versions