Difference between revisions of "Help:Template"
Line 1: | Line 1: | ||
{{TOC|right}}A template is surrounded in double curly braces: <code style="font-size: 10pt"><nowiki>{{NameOfNewTemplate}}</nowiki></code>. | {{TOC|right}}A template is surrounded in double curly braces: <code style="font-size: 10pt"><nowiki>{{NameOfNewTemplate}}</nowiki></code>. | ||
+ | |||
+ | ==Passing Parameters== | ||
==Making Templates== | ==Making Templates== |
Revision as of 16:44, 4 November 2007
{{NameOfNewTemplate}}
.
Passing Parameters
Making Templates
First 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 make 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
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}}}
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}} | 12174528
|
[MW1.5+] The unique identifying number of a page, see Help:Diff. Note that when editing a page, this value is null. |
{{REVISIONDAY}} | 4
|
[MW1.8+] The day on which the page was last modified. |
{{REVISIONDAY2}} | 04
|
[MW1.8+] The day on which the page was last modified, but with a leading zero (01 .. 31). |
{{REVISIONMONTH}} | 11
|
[MW1.8+] The month in which the page was last modified. |
{{REVISIONYEAR}} | 2007
|
[MW1.8+] The year in which the page was last modified. |
{{REVISIONTIMESTAMP}} | 20071104164428
|
[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 |