TemplateData
-
- Last edited 4 years ago by Mgessner
-
-
- This page is a draft but has an approved version
The TemplateData extension makes it easier for users to work with templates. Here we will show you how to quickly create a template with parameters using TemplateData, whose values can then be easily entered by users via a form.
Features of TemplateData
- Day
<templatedata>
: Description of template parameters (e.g. description, type, label) - Format: JSON
- Administration: Via "TemplateData" dialog in the VisualEditor
- Form: Users receive a form for data input
Describe template
Create a template with parameters. On the wiki pages where this template is included, you can then enter the values for the parameters. To make this as easy as possible for the users, describe the template and the parameters.
Save the template. After saving, the TemplateData button appears. Click on the button:
Enter a description for the template and save the form (1). Click on "Manage template data" again. Select "Block" as wikitext formatting (2). The parameters are clearly displayed in the source code of the wiki page in paragraph format.
The template editor has recognized the already existing parameters. You can now define them further. So click on "add suggested parameters" (3). You can then edit the parameters individually.
Click on the first parameter. The editing form appears.
Enter the information for this parameter (see the description of the input fields) and then click Done. Edit all parameters of your template.
After all parameters are described, click Apply on the main page of the template editor. The template source code now contains the template description in JSON format. To avoid this description being included on the wiki pages themselves, it is stored in the ... tag to exclude it from inclusion.
Now save the template. In view mode, the description of the template is now displayed with the parameters.
Über der Beschreibung wird die Vorlage selbst angezeigt. Diese Anzeige kann unterbunden werden, indem die Vorlage in das Tag eingeschlossen wird.
Description of the parameter input fields
Key | Type | Default | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Name
|
InterfaceText | null
|
A very short name for the parameter (e.g. under 20 characters) | ||||||||||||||||||||||||||||
Aliasse
|
Array containing strings | []
|
List of alias names. An alias is an alternative name for a parameter. It can be used instead of (but not in addition to) the primary name. Alias names are not documented in a separate parameter object. If they need more information, they should be given their own attribute, which is marked as "obsolete". | ||||||||||||||||||||||||||||
Description | InterfaceText | null
|
A short description of the parameter so that users know which one to select from a drop-down list. | ||||||||||||||||||||||||||||
required | boolean | false
|
Whether the parameter must be specified for the template to work (value is "true" if this parameter must be specified) | ||||||||||||||||||||||||||||
proposed | boolean | false
|
Whether the parameter is suggested for the template to be useful (true if this parameter should be specified). | ||||||||||||||||||||||||||||
obsolete | boolean or string | false
|
Whether the parameter is deprecated. The value can be a string of instructions giving the user guidance what instead can be done, or be simply true .
| ||||||||||||||||||||||||||||
Standard
|
InterfaceText | null
|
The default value that the template uses for this parameter if no value is specified, or a description of it. | ||||||||||||||||||||||||||||
Autowert
|
string | null
|
A dynamically-generated default value in wikitext, such as today's date or the editing user's name; this will often involve wikitext substitution, such as {{subst:CURRENTYEAR}} .
| ||||||||||||||||||||||||||||
Example | InterfaceText | null
|
Example text for the user to enter a suitable value. | ||||||||||||||||||||||||||||
Typ
|
string | "unknown"
|
The parameter type, as (soft) type hint. One of the following:
|