Help:Templates
From Ask Dr Wiki
|
Templates are pages that can be included inside other wiki articles.
Creating templates
You may create a template in the same you create a normal page, but you must use the namespace template: before the template name. Example: Template:Lastupdate
That page was edited just like any other wiki article, but, as you can see, there is a <noinclude> tag inside it. Noinclude tags are used to add text and code to a template that won't be used when the template itself is called. This is mostly used to add a categories to it, and usage comments when parameters are needed. For more help with categories,look at Help:Categories.
Template Usage
You can make a simple template call by using {{TemplateName}}.
Example:
{{DramaLlamaSmall}}
will show as
| http://wiki.urbandead.com/images/thumb/6/64/Llama.JPG/60px-Llama.JPG | Drama Llama |
| The Llama is watching you. |
Variable in Templates
Variables in templates are areas of the template that can be changed by whoever uses it. Template:DrunkLevel uses variables.
To create a variable, surround it in three sets of curled brackets, like so:
{{{ExampleVariable}}}
We'll use the template above as an example.
{| style="border:solid #556655 2px;" width=250 align="center"
|-
| rowspan=2 | [[Image:Martini.jpg|40px]] || style="background:#556655; color:#ffffff;" width=200 align="center" | '''Sobriety'''
|-
| align="center" style="font-size: xx-small" | {{{User}}} is a currently {{{Level}}}
|}
Notice the variables {{{User}}} and {{{Level}}}. These can be set when the template is used. In this case, the user of the template would put it on thier page as follows. Notice the pipes to separate the variables:
{{DrunkLevel|User=I|Level=so drunk, I can't use grammer}}
The above will produce this:
| http://wiki.urbandead.com/images/thumb/a/a2/Martini.jpg/60px-Martini.jpg | Sobriety |
| I is currently so drunk, I can't use grammer |
Handy Resources
When creating templates, keep the following resources in mind
| |||||
