Extension:TemplateFormEditor/Example
Contents |
[edit] Example
| Language: | English • Deutsch |
|---|
[edit] Defining a Template which uses the Form-Editor
First condition: your template must contain at least one parameter. The parameter can be named or unnamed.
Second condition: your template must define the type of its parameters
Here is a simple example: The sourcecode of the page "Template:Bugreport"
= Introduction =
This template is used as a headline for a bug report
= The Template itself =
<onlyinclude>
= Bugreport=
{|
|-
!Operating System
|{{{Operating System}}}
|-
!Application
|{{{Application}}}
! Version
|{{{Version}}}
|-
!Area
|{{{Area}}}
|}
== The bug can be reproduces as follows ==
{{{1}}}
</onlyinclude>
= Type Definiton =
<typedefinition>
* Operating System : oneof (Windows NT,Windows XP, WindowsVista,
Linux 2.4.x,Linux 2.6.x, FreeBSD, MacOS X) // choose one!
* Application : - // Official Name.
* Area : someof ( Documentation, GUI, Database, other)
* 1 : text (60,10) "can be reproduces as follows:"
</typedefinition>
[edit] Using a Template
After you have created the template shown above you can use it:
- Create a new article e.g. "Bugreport 0815"
- the default editor appears.
- write "{{Bugreport}}" into the textbox and push the button "show preview"
- Now the form-editor is shown. - the following screenshot shows this example on a german wiki
screenshot of the form generated by this extension
Up to now it only makes sense to use the Form-Editor provided by this extension with articles that only contain one template
[edit] Combinations with other extensions
Defining parameter types in the template definition page has two disadvantage:
- e.g. defining a "oneof" or "someof" element with 10 elements you can not define which of these elements are shown at which page
- when new options are needed you need to edit the definition page.
Using the Extension:RegexParserFunctions and Extension:DynamicPageList inside the type definition you can define a dynamically calculated set of allowed values:
E.g. the following definition defines that allowed values are the Titles of all Pages of category "MyCategory"
*page:someof (
{{#regex:{{#regex:{{#dpl:category=MyCategory|notcategory=Template|mode=inline|format=,%TITLE%# ,,}}|%#$%|}}|%#%|,}}
) "A Page" // All currently existing pages of category MyCategory are listed.
The following defines that parameter a and b are only available on a pages containing "AB Page" in its page name:
* parameter:oneof ( {{#regex:{{#regex:{{#regex:{{FULLPAGENAME}}|%^.*AB Page.*$%|#}}|%[^#]%|}}|%#%|a,b,}} c , d )
