Difference between revisions of "Help:Templates"

From Twinsuniverse
Jump to: navigation, search
m (1 revision)
Line 1: Line 1:
 +
{{stub}}
 +
 
{{Help}}
 
{{Help}}
  
Line 72: Line 74:
 
Age=Adult}}
 
Age=Adult}}
  
[[Category:Twinsunica - Help|Templates]]
+
[[Category:Knowledge Base - Help]]

Revision as of 16:47, 24 October 2012

  This article is a stub [list all]. You can help the Twinsuniverse by expanding it.

Template:Help

A template is an editing technique in MediaWiki, which enables displaying the contents of one page in another, without copying and pasting. A template is a page which can be "planted" in another, and is used to avoid duplications and maintain consistency.

The implementation of a template in a page is similar to linking to a page, only that except square brackets ([[Link]]), we use curly brackets ({{Template}}.

Creating a new template

To create a new template, enter the editing window of any article, and write the following text anywhere:

{{Template name}}

(replace "Template name" with the name you wish to assign to the template, of course)

Click the Show preview button, and you will get a red link which looks like that:

Template:Template name

Click on the link, and you will be taken to the template's editing window. Edit it like any other page, and save it. To embed the template in other pages, add the line {{Template name}} where you want the template displayed, replacing "Template name" with the name of your template.

Parametric templates

There is also the possibility to add parameters to templates, which are changeable in every page. To add a parameter to a template, in the template page put three curly brackets around the word you wish to make a parameter. For example:

{{{Name}}}

Note that parameters are case-sensitive, and "Name" will not be similar to "name".

To use a parameter in the target page, use the following order:

  • {{
  • Template name
  • |
  • Parameter name
  • =
  • Parameter's value
  • }}

For example:

{{Character|Name=Twinsen}}

If there are many parameters in the template, you can also add a line break between them, to make it easier on the eye:

{{Character
|Name=Twinsen
|Race=Quetch
|Size=Medium}}

Default value for a parameter

It is possible to define a default value for parameters, which will be used if no value was written for the parameter in the target page. To do so, after the parameter's name in the template page, add "|default text". For example:

{{{Name|Unknown}}}

An example of a template usage

Template:Character:

{| border="1" align="right" style="background:lightblue; color:black"
|-
|
<p align=middle><font size=+1>{{{Name}}}</font><br>
[[Image:{{{Image}}}]]<br></p>
'''Race:''' {{{Race}}}<br>
'''Gender:''' {{{Gender}}}<br>
'''Size:''' {{{Size}}}<br>
'''Age:''' {{{Age}}}
|}

Implementation:

{{Character|
Name=Twinsen|
Image=TWINSEN.jpg|
Race=[[Quetch]]|
Gender=Male|
Size=Medium|
Age=Adult}}

Result: Template:Character