Help:Template
Contents
A template is a wiki page whose contents are specially intended to be inserted into another wiki page by the "transclusion" process. It's also a simplified way to enhance your text or use html code without having to know code! When you use a template, the template name is surrounded in double curly braces: {{NameOfTemplate}}
.
See Wiki Templates for our most frequently used and popular templates.
If you're interested in an advanced understanding of templates, just keep reading. If you're interesting in creating them, see the Creating Templates section of this page.
Passing Parameters
Named Parameters
Named parameters are parameters which have a name to them. For example, the Template:www.ribaotechnology.com
template uses named parameters. To use the DomainPage template, you would use code such as the following:
{{ Domain_Page | reviews = <reviews></reviews> | vote = <vote></vote> | thumbnail = <thumbnail>AboutUs.org</thumbnail> | map = <map section="Address"></map> }}
Do not be confused in this example - the tags being passed, such as <reviews></reviews>
, are not necessary to pass named parameters. The tags themselves are being passed to the template.
In this example, reviews
, vote
, thumbnail
, and map
are all named parameters, because you must specify their name. Named parameters need to have an equal sign ( =
) between the name of the parameter and the value.
|
) at the end of each line. This separates the previous parameter from the next. Now you are probably thinking, "then why do we need a pipe if we need to place the parameters on separate lines?" The thing is, you don't have to put them on separate lines. You can if you want. This template could be condensed into one line: {{ Domain_Page|reviews = <reviews></reviews>|vote = <vote></vote>|thumbnail = <thumbnail>AboutUs.org</thumbnail>|map = <map section="Address"></map>}}
Sequential Parameters
Sequential parameters do not have a name to them. It all matters in what order you pass them. For example, the {{color}}
template engages sequential parameters. To use this template you would use:
{{color|Black|Blah blah blah blah blah.}}
Because this template is using sequential parameters, switching the two around (Black
) would not give the desired output.
But then, how would you skip a parameter? Very simple. Simply leave a blank value. For example, Blah blah blah blah blah.
(notice that the color parameter is skipped).
Of course, sequential parameters, like named parameters, must be separated by a pipe. And just like named parameters, you could place the parameters on separate lines.
Creating Templates
Before you create your template, make sure the template doesn't already exist by going to Special:Prefixindex and selecting Template from the namespace drop-down box.
When you are ready to create your template, go to http://www.aboutus.org/Template:NameOfNewTemplate
(replacing NameOfNewTemplate with whatever you wish to call it). Make sure that the name of the template is not too long, but is descriptive enough of its function, and the name is easy enough to remember.
Your template can be simple, like {{smiley}}
, or as complex as {{CategoryTOC}}
.
MagicWords
MagicWords can be considered a predefined template without parameters.
This is a list of MagicWords that can be used in the wikitext. The way they are rendered vary with time (directly depending on time, or e.g. for number of articles, depending on the creation of other articles), on the project (it changes when the wikitext is copied), or on the page in which it occurs (it changes when the wikitext is copied, when the page is renamed, and when the page is included in another page).
Receiving Passed Parameters
Named Parameters
Receiving passed parameters to a template is very easy. All you have to do is surround the name of the parameter in triple quotes where you want it in the template. For example, a template which would show the contents of the text
parameter would be coded like this:
{{{text}}}
Sequential Parameters
Sequential parameters are quite the same thing, only you would use the number of the parameter, which starts at 1:
{{{1}}}
You can put the parameters in any order you want, for example:
{{{1}}} is a {{{2}}}. {{{1}}} likes {{{3}}}.
Default Values
If you want to have a default value for the parameter, which is shown if the template is embedded without specifying the parameter, you can add a pipe ( |
) to the end of the name of the parameter, followed by the default value. For example,
{{{text|Default Value}}}
Important Notes
When a parameter is not passed, and there is no default value, the parameter will be read as text. That means that {{{x}}}
, replacing x with the name of the parameter being used will be seen in the place it is used.
List of MagicWords
Constants
{{SITENAME}}
|
AboutUs | |
{{SERVER}}
|
//aboutus.com | |
{{SERVERNAME}}
|
aboutus.com | |
{{CONTENTLANGUAGE}}
|
en | code of the site's default interface language |
Dependent on page
Word | Example | Explanation |
---|---|---|
{{PAGENAME}} | Template
|
Returns the name of the current page, including all levels (Title/Subtitle). |
{{PAGENAMEE}} | Template
|
More URL-friendly percent encoded special characters (To use an articlename in an external link). |
{{SUBPAGENAME}} {{SUBPAGENAMEE}} |
Template
|
[MW1.6+] Name of the current page, excluding parent pages ("Subtitle" on "Title/Other/Subtitle") in namespaces supporting subpages, see Help:Link. |
{{BASEPAGENAME}} {{BASEPAGENAMEE}} |
Template
|
[MW1.7+] The basename of a subpage ("Title/Other" on "Title/Other/Subtitle"), see Help:Link. |
{{NAMESPACE}} {{NAMESPACEE}} |
Help
|
Returns the name of the namespace the current page resides in. |
{{FULLPAGENAME}} {{FULLPAGENAMEE}} |
Help:Template
|
[MW1.6+] Shorthands for NAMESPACE+PAGENAME |
{{TALKSPACE}} {{TALKSPACEE}} |
Help talk
|
[MW1.7+] Name of next odd namespace (e.g. 4 => 5) |
{{SUBJECTSPACE}} {{SUBJECTSPACEE}} |
Help
|
[MW1.7+] Name of last even namespace (e.g. 5 => 4) |
{{ARTICLESPACE}} {{ARTICLESPACEE}} |
Help
|
[MW1.7+] An alias for SUBJECTSPACE(E) |
{{TALKPAGENAME}} {{TALKPAGENAMEE}} |
Help talk:Template
|
[MW1.7+] FULLPAGENAME in its TALKSPACE |
{{SUBJECTPAGENAME}} {{SUBJECTPAGENAMEE}} |
Help:Template
|
[MW1.7+] FULLPAGENAME in its SUBJECTSPACE |
{{ARTICLEPAGENAME}} {{ARTICLEPAGENAMEE}} |
Help:Template
|
[MW1.7+] An alias for SUBJECTPAGENAME(E) |
{{REVISIONID}} | 18094200
|
[MW1.5+] The unique identifying number of a page, see Help:Diff. Note that when editing a page, this value is null. |
{{REVISIONDAY}} | 13
|
[MW1.8+] The day on which the page was last modified. |
{{REVISIONDAY2}} | 13
|
[MW1.8+] The day on which the page was last modified, but with a leading zero (01 .. 31). |
{{REVISIONMONTH}} | 03
|
[MW1.8+] The month in which the page was last modified. |
{{REVISIONYEAR}} | 2009
|
[MW1.8+] The year in which the page was last modified. |
{{REVISIONTIMESTAMP}} | 20090313205011
|
[MW1.8+] ISO 8601 time stamp, indicating when the page was last modified. |
{{SITENAME}} | AboutUs
|
Value of $Sitename. |
{{SERVER}} | //aboutus.com | Value of $Server |
{{SCRIPTPATH}} |
|
[MW1.5+] $ScriptPath |
{{SERVERNAME}} | aboutus.com
|
[MW1.5+] $ServerName |