No categories assigned

TemplateData

< Manual:Template
Revision as of 12:32, 24 November 2020 by Mgessner (talk | contribs)

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.

Manual:650px-vorlage-templatedata-beforesave.png





Save the template. After saving, the TemplateData button appears. Click on the button:

Manual:220px-vorlage-templatedata-schaltfäche.png

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.

Manual:650px-vorlage-templatedata-fenster.png

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.

Manual:650px-vorlage-templatedata-parameter-definieren.png

Click on the first parameter. The editing form appears.

Manual:650px-vorlage-templatedata-editor.png

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.

Manual:650px-vorlage-templatedata-quelltext.png

Now save the template. In view mode, the description of the template is now displayed with the parameters.

Manual:650px-vorlage-templatedata-output.png

Ü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:
String Value Type of Parameter
"unknown" Assumed type if not set
"number" Any numerical value (without decimal points or thousand separators)
"string" Any textual value. May contain line breaks.
"line" Short text field – use for names, labels, and other short-form fields. This is supposed to be text that is not expected to contain line breaks.
"boolean" A boolean value ('1' for true, '0' for false, '' for unknown), see three-valued logic.
"date" A date in ISO 8601 format, e.g. "2014-05-09" or "2014-05-09T16:01:12Z"
"url" A URL, including protocol, e.g. "http://www.example.org", "https://example.org", or "//example.org".
"wiki-page-name" A valid MediaWiki page name for the current wiki. Doesn't have to exist, but if not, should be a valid page name which could be created.
"wiki-file-name" A valid MediaWiki file name for the current wiki. Doesn't have to exist, but if not, should be a valid file name which could be uploaded. Should not include the namespace (e.g. "Foo.svg" not "File:Foo.svg" or "Bild:Foo.svg").
"wiki-template-name" A valid MediaWiki Template name for the current wiki.
"wiki-user-name" A valid MediaWiki user name for the current wiki. Doesn't have to exist, but if not, should be a valid user name which could be created. Should not include the namespace (e.g. "Foo" not "User:Foo" or "Usario:Foo").
"content" Page content in wikitext, such as text style, links, images, etc.
"unbalanced-wikitext" Raw wikitext that should not be treated as standalone content because it is unbalanced – for example, templates concatenating incomplete wikitext as a bigger whole, such as {{echo|before=<u>|after=</u>}}

Attachments

Discussions