Hi. this is the first time i write here, so please forgive any breech of protocol - they are not intended.
i contribute mostly on hewiki, and very lightly on enwiki. in hewiki, after some deliberation, it became clear that many editors have difficulty with parametric templates. to alleviate the problem, i developed a "template parameters wizard". the wizard adds a button to the "advanced" toolbar that looks like so: {{}}. pressing this button opens a small dialog box that allows the editor to type in the template name (with autocomplete from the template space. if a template is selected in the editor window, then this step is skipped). after selecting the template, a main dialog opens, with the list of all the parameters this template supports, and an input line for each parameter. there are 2 modes of operation:
- for all templates, the wizard will extract the parameter list from the template itself.
- however, if the template selected has a subpage named "Parameters", the wizard will get the parameters from this subpage instead of the template itself. this enables added features, such as descriptions, define parameters as "Mandatory", give default values for parameters, define parameters as "select value from a list", specify fields as "multiline", and some more useful features.
When selecting a partially populated, existing template on the page and then pressing the button, the wizard will pre-populate all the fields which already have values. the wizard operates in hewiki since around February 2012, and in arwiki since mid August.
if you want to try it, add to Special:MyPage/common.js the following line:
importScript('User:קיפודנחש/TemplateParamWizard.js');
if you want to discuss it, best way to reach me is on he:User Talk:קיפודנחש, although i do occasionally read my talkpage on enwiki. קיפודנחש (talk) 23:23, 27 September 2012 (UTC)
- Copied from Wikipedia:Village_pump_(technical)/Archive_103 ~Adjwilley (talk) 21:08, 19 November 2012 (UTC)
The Parameters subpage
editA template can have a "Parameters" subpage, which tells the wizard how to lay out the dialog box. The structure of this page is described here. The page is structured as a 3-column table, where each row represents one parameter. The table needs to be laid out in such a way that each row is laid using a single line, using double-bar ( || ) separating the columns. The three columns are: The parameter name, a description, and options. The parameter name is mandatory, the description and the options are optional. Here is an example:
{| class="wikitable" |- ! Param name !! Description !! Options |- | param1 || Description of param1 || Options for param1 |- | param2 || Description of param2 || Options for param2 ..... |}
The description can contain wikicode, including internal and external links. The options are described below.
Options
edit- Required
- Default
- Choices
- Depands on
- Extended
- Multiline
Options can be combined where it makes sense, in which case the different options are separated by semicolons. Some options can have values. when they do, the Equal sign, "=", separates the option name from the value.
Required
editThis option does not have a value. A parameter with this option can't be empty. For as long as any parameter with this option is empty, the "OK" button is disabled.
Default
editThis option has a value. This value is filled in as the value of the parameter when the dialog is opened.
Choices
editThis option has a value. A parameter with this option will not have a text input field in the wizard, and instead will have a drop-down menu, allowing the editor to select which of the choices to use. the different choices are delimited with commas. e.g.:
- Choices = Red, Green, Blue, White
It is possible to use single choice, like this:
- Choices = Alive
In this case, instead of a menu, the wizard will display a checkbox. If the user marks it, the template will contain, in this case, "|paramname=Alive".
Depends on
editThis option has a value, which is the name of one of the parameters of the template. When a parameter "Depends on" another parameter, the input row for the first parameter is not visible as long as the parameter it depends on is empty. This can be useful, for example, when a template has parameters like "Author1", "Author2", "Author3", "Author4", we can make the Author4 parameter depend on the Author3 parameter, which in turn depends on Author2, which depends on Author1. this way, the wizard only shows the "Author1" field when it opens, but as soon as the user enters a value for this parameter, "Author2" becomes visible, and so on.
Extended
editThis option does not have a value. Fields with this option are not visible when the wizard first appears. If the template has one or more parameters with this option, the wizard will have a checkbox "Show all fields" to show and hide the parameters marked "Extended".
Multiline
editThis option can have a value, but it is not required. This option tells the wizard to use a Textarea for the value of this parameter, rather than a text input line. The optional value of this option is the number of lines (height) of this textarea. When it does, the value is the number of lines in the textarea used to enter the value of this template parameter. If this option does not have an explicit value, a default of 5 lines will be used.
Examples
editThis example will be the options for the "border color" parameter. We want to allow 4 colors: red, green, blue and black, but also, we want this parameter to only show in the wizard if parameter "border" is selected.
| border color || Choose a color for the border || Depends on = border; Choices = red, green, blue, black