Help:Template
From WikiGlide
In MediaWiki, a template is a page which can be inserted into another page via a process called transclusion. It is comparable to a subroutine.
This page and its extension Help:Advanced templates provide a reference manual on templates in MediaWiki. For an introduction, see A quick guide to templates.
Notes:
- The master version of this page is the page m:Help:Template on Meta-Wikipedia; template demos work there, but may not work if you are viewing a copy of this page on another project.
- Templates can be used to control (part of) the page body, but not the margins (logo, sidebars, etc.). These are controlled by the skin, the user style, and part of the contents of the MediaWiki namespace.
General
The template namespace is the namespace with prefix "Template:" (this prefix can be used in all languages, but the canonical prefixes in languages other than English include Vorlage, Modèle, Sjabloon, with colon; the site WikiFAQ calls it Snippet).
A page in this namespace is called a template. The contents of such a page (either fixed or depending on parameters and/or variables) is designed to be useful for insertion in other pages (transclusion, creating a compound document).
The syntax for insertion of the page "Template:name" is {{name}}. This is called a template tag. Example: abc{{tc}}def (using Template:tc containing "in") gives abcindef.
This reference in the wikitext causes insertion of the template content when the referring page is rendered. Various equivalent terms are:
- calling the template
- referring to the template
- including the template
- transcluding the template
- using the template
If the page "Template:name" does not exist, then {{name}} works as [[Template:name]], a link to a non-existing page, leading to the edit page. Thus, one way of making a template is putting the tag first, and then following the link.
If name starts with a valid namespace prefix, or a colon, then it is not prefixed with "Template:". This way any page can be used as template (a colon at the start refers to the main namespace).
However, a page in the template namespace has advantages:
- they are listed on the edit page of pages that call the template
- when a page in the template namespace is changed, all the other pages that link to it automatically have their server caches (as opposed to browser cache) purged. With other namespaces, you need to purge the server cache manually.
Also it provides an alternative way of calling a template, which can be used in the case of a name conflict with a variable, e.g. Template:Ns:3 and Template:PAGENAME.
In the case of an image or category, it gives the description part. E.g. {{Image:tst.png}}, referring to Image:Tst.png (talk, backlinks, fw links, edit), gives Image:Tst.png
However, if the image is on commons, the template call is treated as a link, which in turn is the embedding command, so the image is embedded: {{Image:Map South Holland.png}} gives:
Using a page outside the template namespace as template can be useful for:
- quoting interface messages in the MediaWiki namespace
- templates for personal use in subpages of one's userpage, e.g. for experimenting
- inclusion of pages in other pages in the same namespace, e.g. having an extra page associated with each page, such as a to-do list, with a simple name correspondence; it can be created and included with {{{{NAMESPACE}}:{{PAGENAME}}/todo}}.
As usual the template name is case sensitive except (on most projects) for the first letter, and a blank space is equivalent with an underscore (as opposed to parameter names, see below: they are case-sensitive, even with respect to the first letter, and spaces are distinguished from underscores).
One can call a template that calls another template. If a template calls itself directly or indirectly, inclusion works only on one level for each template. However, with templates redirecting to the template that one would want to call recursively, one can achieve recursion without having to make copies of the whole template content, with the number of levels limited by the number of redirects. See also Repetition within a page and Template:List of template calls (talk, backlinks, edit).
A variable in a template is evaluated after insertion in the referring page, i.e. if {{PAGENAME}} occurs in the wikitext of a template, it is rendered as the name of the referring page, not the name of the template.
A list of templates used on a page, all with links, is given on the edit page. Notes:
- only those in the template namespace are given, not pages in other namespaces, transcluded in the page
- even on a section edit page the whole list is given, i.e. also the templates used in other sections
- even when editing an old version of a page, the list is given for the current version
- templates for which the tags have not been saved yet are not shown, even on the preview page
(Supported in version 1.4 and higher.)
When saving a page without newline at the end, and going to the edit page again, there is a newline at the end. However, this does not seem to have effect, see the example above and the following example:
{{Numbered list demo}}{{Numbered list demo}}
{{Numbered list demo}}
using Template:Numbered list demo, gives
- Amsterdam
- Rotterdam
- The Hague
- Amsterdam
- Rotterdam
- The Hague
- Amsterdam
- Rotterdam
- The Hague
Use of templates across projects
A template only works when referred to from a page in the same project. To use it in another project, one has to copy it to there. Bugzilla:1126 is a request to lift that restriction, i.e. allow interwiki use of templates.
The adjustments needed in the copy, to work on the other project, can be reduced by using {{SERVER}}, localurl, and generic namespace names, and writing links in a way that works on multiple projects, e.g. m:Help:Table. For copying multiple templates, export and import can be helpful. It is also convenient if the template names can be the same on the other project. Therefore, when choosing template names, check which names are in use on other projects to which people might want to copy the templates. Note that if a template is referred to by something like abc{{NAMESPACE}}, a project with different namespace names requires a different template name, or a redirect.
Transclusion across projects, hence changing contents from a central place, is only possible:
- for content in the form of an image on Commons, to any page,
- for editable content on an image page on Commons, including content transcluded from other pages on Commons, to the corresponding local image pages, if there is no local image with the same name
- Those on the central Wikicities work in the separate Wikicities projects, provided that the prefix "wikicities:" is used, see wikicities:Help:Shared templates.
- Please note that these external Wikicities projects are NOT hosted and managed by the Wikimedia Foundation.
Parameters
Template parameters are either named or numbered. They are called-by-value, and therefore input parameters only.
In the template definition, the formal parameter (the placeholder for the parameter value) is a parameter name with three pairs of braces. So, for example, you would write {{{myVariableName}}} for a template parameter which you wanted to call myVariableName.
| MediaWiki version: | 1.6 | (for parameters defaults) |
In the template call, the syntax is either
- {{templatename|parname1=parvalue1|parname2=parvalue2}} with tags {{{parname1|default}}}, {{{parname2|default}}}, etc. in the template, or
- {{templatename|parvalue1|parvalue2}} with tags {{{1|default}}}, {{{2|default}}}, etc. in the template.
The default (optional, together with the pipe character in front) can be different for every occurrence, and applies if no value is specified when calling the template, not to be confused with the case that the empty value is specified.
Example: named parameter substitution
Let us create a template called Name_example (that is, the template will be Template:Name_example), with a parameter for the first name which we will call firstName, and a parameter for the last name which we will call lastName.
If we call the template without any parameters, i.e. if we write {{Template:Name_example}}, then we will get:
- I am a template example, my first name is {{{firstName}}} and my last name is {{{lastName}}}.
However, now if we call it and pass parameters to it as follows:
{{Name_example | firstName=John | lastName=Smith}} the output will look like this:
- I am a template example, my first name is John and my last name is Smith.
Example: numeric parameter substitution and use of a default
An example of how the contents of a parameter function:
Let us first define a template with the name t which contains a single numbered parameter 1 with a default of pqr:
- start-{{{1|pqr}}}-end
the definition of course being on page Template:t.
- Calling the template called t with a parameter value of "a", i.e. {{t|a}} gives "start-a-end".
- Calling the template called t with a parameter which is blank: i.e. {{t|}} gives "start--end".
- Calling the template called t and not passing any parameters: i.e. {{t}} gives "start-pqr-end".
Template mechanism
The template mechanism involves the following steps:
- in template calls the template name, parameter names and parameter values depending on variables are evaluated; the result of this step can be viewed by applying subst (possibly multiple times), save and edit, see below; in the case of a variable depending on a variable this may have to be done a second time;
- the values are assigned to the parameters from left to right (the result can not be directly viewed), meaning that a named or numbered parameter may be specified several times, the last one being the actual value that will be kept when passing the parameter during the final instantiation of the template below.
- template calls are replaced by template content, where the parameter tags with matching names are replaced by their values or defaults (the result of this step can be viewed by applying subst either again, or directly to the template and the variables).
The process is applied recursively until there are no more template calls to replace.
All whitespaces before and after a parameter value are usually ignored.
- "{{t| a}}" gives "start-a-end".
- "{{t|a }}" gives "start-a-end".
A parameter value can contain a piped link; the "|" in such a link is not taken as parameter separator.
(In this case the space has effect.)
On rendering, surplus parameter values (including named parameters that do not occur in the template) are ignored: {{t|a|b}} gives start-a-end.
Parameters without names (i.e. that don't contain an equal sign) are numbered implicitly starting by 1, from left to right.
- Example: "{{t|a|b|c}}" is equivalent to "{{t|1=a|2=b|3=c}}"
Numbered parameters can also be skipped or can be specified in alternate order by numbering them explicitly.
- Example: "{{t|3=c|2=b|1=a}}" is equivalent to "{{t|1=a|2=b|3=c}}"
- Example: "{{t|a|b|c|10=j}}" is equivalent to "{{t|1=a|2=b|3=c|10=j}}"
This also makes it possible to apply a default value for parameter 1, while specifying a value for parameter 2:
{{t2d|2=a}}, using Template:t2d (talk, backlinks, edit) containing "start-{{{1|p}}}-middle-{{{2|q}}}-end", gives start-p-middle-a-end.
Template calls can contain multiple occurences of the same named parameter, and a numbered parameter can be specified multiple times by using its number explicitly. The effective value of parameters is the value of the last occurence (from left to right) of the parameter with the same name, once the parameter names have been evaluated.
- Example: "{{t|a|b|c|2=B}}" is equivalent to "{{t|a|B|c}}"
The final list of formal parameters before the template itself is instanciated is then unordered because the list is indexed by the evaluated parameter named (this list is an associative array).
A useful example that uses of multiple assignments of parameters with the same name (and thus allowing parameter overrides) is performed in the en:Template:If defined call1 template used for example in English Wikipedia (and many other localized editions).
See also Help:Parameter default.
Restrictions on parameter values
- If a parameter value contains an equals sign, the parameter name must be put explicitly, even when it is 1, 2, 3, etc.
- If the expression for a parameter value contains two consecutive closing braces which are not part of a variable or parameter tag, they have to be put in nowiki tags.
- If the expression for a parameter value contains a pipe character (|) which is not part of a piped link or within an image tag, it has to be put in nowiki tags: <nowiki>|</nowiki>.
- The expression for a parameter value cannot contain the variable localurl with query string, due to the pipe character.
- A parameter value can be quite long, see Help:Long parameter demo.
- A parameter value can contain pairs of square brackets or text to be used within a link, but not a closing part of one link and an opening part of another link: {{tlis|abc]]def[[ghi}} using Template:tlis (talk, backlinks, edit) containing
"[[a{{{1}}}b]]"gives {{tlis|abc]]def[[ghi}}
Named vs. numbered parameters
Advantage of numbering:
- in the template call no name or "=" is needed; this means less to type and also less to memorize or lookup (on the other hand, one has to memorize or lookup the order); an exception is when the value contains "=": then the other equals sign is needed, with the parameter number in front.
- numbers are international, both in the template tags and in the parameter tags in the template, no parameter name has to be translated (alternatively, one can e.g. use English names, only editors would see them and need to understand them)
Advantages of naming:
- the order of specifying the values does not matter
- a dummy unnamed parameter for comment and for formatting the template call can be inserted at any time, without planning in advance or renumbering (in the case of unplanned insertion of a dummy parameter between numbered ones, the text has to contain an equals sign; this works even if there is a newline somewhere before the "=", although a newline is not allowed in a parameter name).
- the template is easier to understand
- some special techniques use the fact that multiple assignments of values to the same parameter in the same template call is allowed and results in the last value being used; this implies that at least one parameter name is specified explicitly in the template call
Mix of named and unnamed parameters
In the case of a mix of named and unnamed parameters in a template tag, the unnamed parameters are numbered 1,2,3,.., so they are not numbered according to the position in the mixed list as a whole.
For example, {{t sup|3=1|2|1=3|4|5|6|7}} using Template:t sup containing "{{{1}}}-{{{2}}}-{{{3}}}" gives 3-4-5.
Template tag lay-out
To have a desired template tag lay-out, especially in the case of many parameters, additional dummy parameters can be used with a newline, spaces, and/or comments. In the case of unnamed parameters, this means that some parameter numbers are not used in the template content, so that their values, present in the template tag, do not affect the rendering of the template. For example, using Template:t3d containing "{{{1}}} {{{2}}} {{{3}}}<br /> {{{5}}} {{{6}}} {{{7}}}<br /> {{{9}}} {{{10}}} {{{11}}}",
{{t3d |a|b|c| 1
|d|e|f| 2
|g|h|i| 3
}}
gives:
a b c
d e f
g h i
If parameters are named, dummy parameters can easily be inserted at any time. If they are unnamed, then, to avoid renumbering, one can insert named parameters: any text including an equals sign will do, if the text on the left is not one of the parameter numbers: this text is interpreted as the name of an unused parameter, hence ignored.
Example:
Using Template:Chess position (talk, backlinks, edit)
{{chess position|=
8 |rd|nd|bd|qd|kd|bd|nd|rd|=
7 | |pd|pd|pd|pd|pd|pd|pd|=
6 |pd| | | | | | | |=
5 | | | | | | | | |=
4 | | | | | | | | |=
3 | | | | | | | | |=
2 |pl|pl|pl|pl|pl|pl|pl|pl|=
1 |rl|nl|bl|ql|kl|bl|nl|rl|=
a b c d e f g h
|30}}
which gives
In this example, the 1 to 8 row numbers and a to h column numbers (as well as their surrounding spaces and newlines) in the parameter list are hidden within a dummy parameter (with an empty name before the equal sign).
The template generates a HTML table where each cell contains an image whose name is dynamically generated from the 64 first automatically numbered parameters (there are intermediate parameters within the numbered list, but as these dummy parameters are named explicitly, they don't increment the parameter number used to generate default parameter names. So the parameter with autogenerated name "1" effectively contains the "rd" value).
The template is then called with a parameter list that contains:
- 65 parameters automatically named from "1" to "65" (64 parameters for the cells content, and the 65th for the image width),
- and a dummy named parameter (whose name is an empty string, and whose effective value results from the last assignment with the chessboard column names a to h and the surrounding spaces and newlines), which is not used in the internal template content.
Note also that all parameters are trimmed, so the parameter with autogenerated name "17" (at position a6 on the chessboard above) is assigned the empty string value.
Effect of an undefined parameter if no default has been specified
Some parsing problems in earlier versions of the software have been fixed; using Template:t2 containing "start-{{{1}}}-middle-{{{2}}}-end":
- {{t2||}} gives start--middle--end
- {{t2|a|}} gives start-a-middle--end
- {{t2||a}} gives start--middle-a-end
- {{t2|a|{{{1}}}}} gives start-a-middle-{{{1}}}-end
- {{t2|{{{1}}}|a}} gives start-{{{1}}}-middle-a-end
- {{t2|{{{1}}}|{{{2}}}}} gives start-{{{1}}}-middle-{{{2}}}-end
Template page
The following are identical:
- the rendering of the wikitext of the template (this is on the template page, and would be the same in other pages with that wikitext)
- the rendering of the template on a page that calls it without parameters
Thus the defaults are shown, e.g. Template:T 1 (talk, backlinks, edit) containing "abc{{{1|def}}}ghi{{{1|jkl}}}mno" shows the same as {{t 1}}: "abcdefghijklmno".
Template page if no defaults have been specified
In simple cases this corresponds to treating the parameter tags as ordinary text, for example:
"{{t2}}" (using Template:t2 containing start-{{{1}}}-middle-{{{2}}}-end) gives start-{{{1}}}-middle-{{{2}}}-end
Similarly, if part of the parameters is undefined, only those show up as {{{parameter number or name}}}.
However, if a parameter is in another template call, then, as a result of what was explained in the previous section, the template page seemingly demonstrates an error in the wikitext: it is confusing, as a result of parsing the code differently from when it is used, i.e. called with a parameter value.
E.g., the template page of Template:t2a1 containing "{{t2|a|{{{1}}}}}" shows start-a-middle-{{{1}}}-end, and that of Template:t2a3 containing "{{t2|{{{1}}}|a}}" shows start-{{{1}}}-middle-a-end.
Thus, for getting informed about the contents of a template, just looking at the template page is insufficient (because it is ambiguous) and misleading. Note also that variable tags are not shown, but evaluated. However, some formatting aspects may show up which are not readily seen from the edit box.
Template talk page
The template page is of a different nature than other pages. It is not for explaining anything to the reader, but for defining the template for the system (this is done by the wikitext, the rendered page is just a by-product). Therefore the template talk page has an especially important role. It typically consists of two parts:
- the first part explaining the template and its parameters
- preferably examples are given of template calls (put them in nowiki tags) and the results (put the template call without nowiki tags in the wikitext)
- the second part used for the ordinary talk page function
In complicated cases, "subst:" can be very helpful in the explanation, see below.
You can use {{doctl}} for this task.
A parameter value depending on parameters
As mentioned above, if a parameter is left undefined, the triple braced parameter name in the result does not function as a parameter if the page is called as a template from another page; if it should, do not omit the parameter value but specify it in terms of a parameter of the calling page; compare:
- {{t2a|b}} (using Template:t2a containing {{t2|a}}) gives start-a-middle-{{{2}}}-end
- {{t2a1|b}} (using Template:t2a1 containing {{t2|a|{{{1}}}}}) gives start-a-middle-b-end.
- Similarly, {{t2a2|b}} (using Template:t2a2 containing {{t2|a|2={{{1}}}}}) gives start-a-middle-b-end. See also below.
The most straightforward way of expressing a parameter value in terms of a parameter is using the same name and making it equal, e.g. {{Lan is|lr=af|le={{{le}}}}} in Template:Lan is mr.
Remarks
{{t2||a}} makes the first parameter equal to the empty string rather than leaving it undefined: it gives start--middle-a-end. By treating the second unnamed parameter as a parameter with the name "2", the first unnamed parameter can be left undefined.
- Example: {{t2|2=a}} gives start-{{{1}}}-middle-a-end.
If the parameter is used in a tag like <font size> the default text may give invalid code that is conveniently ignored, rather than resulting in perhaps ugly code being rendered (but this may depend on the browser). See e.g. Template talk:Fontsize.
Parameter names (as opposed to template names) are case-sensitive, even with respect to the first letter, and spaces are distinguished from underscores. The empty string is also a valid parameter name, see Template:T empty string as parameter name.
Parameter 02 is distinguished from parameter 2: using Template:t pl0 (talk, backlinks, edit) containing "{{{1}}}{{{2}}}{{{02}}}", {{t pl0|5|6|7}} gives 56{{{02}}}
Note that parameters in the MediaWiki namespace (interface messages) are written differently: as $1, $2, etc., see Meta-Wikimedia:MediaWiki namespace text.
Equals sign in parameter value
When a parameter value contains an equals sign, the parameter name must be stated explicitly, otherwise the part of the parameter value before the equals sign is taken as the parameter name. If that happens accidentally, this parameter is likely to be unused, hence harmless, but the intended implicit parameter 1, 2, or 3, etc., gets no value.
- Example: {{TTT|a=b|c}} (using Template:TTT containing "{{{1}}}{{{2}}}") gives c{{{2}}} (unused parameter a is assigned the value b, the first parameter value for which no parameter name is specified is assigned to the parameter with the implicit name "1" — it reads like so: Use template TTT, assign "b" to the perameter "a", use the value "c" for your first implicit parameter {{{1}}}.), while {{TTT|1=a=b|2=c}} gives a=bc (the first parameter is assigned the value "a=b" — it reads like so: Use template TTT, assign "a=b" to the expressed parameter "1", assign "c" to the expressed parameter "2"). In this case, if template TTT had a parameter {{{3}}}, {{TTT|1=a=b|2=c|d}}, "d" would be assigned to "3" as first implicit parameter without a value.
The same applies if a parameter value depends on a parameter, and may therefore contain an equals sign. Compare:
- {{t2a1|1=x=y}} (using Template:t2a1 containing {{t2|a|{{{1}}}}}) gives start-a-middle-{{{2}}}-end.
- {{t2a2|1=x=y}} (using Template:t2a2 containing {{t2|a|2={{{1}}}}}) gives start-a-middle-x=y-end.
msgnw
The prefix msgnw (short for "message, nowiki") is used to display the uninterpreted wikitext of a template (the same thing you'd see if you were editing the page) on another page. An exception is that numbered and unnumbered lists are rendered as such instead of displaying # or * signs. Parameter values are ignored.
Examples:
- {{msgnw:en}} gives [[English]]
- {{en}} gives English
- {{msgnw:t2|a|b}} gives start-{{{1}}}-middle-{{{2}}}-end
- {{t2|a|b}} gives start-a-middle-b-end
{{msgnw:Numbered list demo}} gives:
- Amsterdam
- Rotterdam
- The Hague
{{Numbered list demo}} gives:
- Amsterdam
- Rotterdam
- The Hague
The edit box shows:
#Amsterdam #Rotterdam #The Hague
Link for editing a template
An edit page shows template tags in the edit box, not the wikitext of the included templates. A list of links is provided to the templates used on the page. To edit a template, one can follow the link, and go to the edit page of the template.
More convenient is to have a special link for editing the template on the calling page. This link can be put in the template itself. Since these edit links are similar for various templates, it can be made a template itself, with the name of the template as parameter. See e.g. en:template:edit and en:Train.
On Meta there are:
For editing a template ({{{1}}} is the name without prefix):
- Template:Ed (talk, backlinks, edit) containing
"<noinclude> ----------Not included from here.----------
For editing a template ({{{1}}} is the name without prefix):
- [[Template:Ed]] - text: edit {{{2}}}
- [[Template:Edi]] - text: +/-
- [[Template:Eda]] - text: {{{2}}}
- [[Template:Edde]] - text: {{{2}}} bearbeiten
For editing any file ({{{1}}} is the full page name):
- [[Template:Edit]] - edit {{{2}}}
[[w:en:Template:Ed]]
----------Not included until here.----------
</noinclude><small class="editlink">[{{SERVER}}{{localurl:Template:{{{1}}}|action=edit}} Edit {{{2}}}]</small>"
- Template:Edi (talk, backlinks, edit) containing
"<small class="editlink">[{{SERVER}}{{localurl:Template:{{{1}}}|action=edit}} +/-]</small>" - Template:Eda (talk, backlinks, edit) containing
"<small class="editlink">[{{SERVER}}{{localurl:Template:{{{1}}}|action=edit}} {{{2}}}]</small>" - Template:Edde (talk, backlinks, edit) containing
"<small class="editlink">[{{SERVER}}{{localurl:Template:{{{1}}}|action=edit}} {{{2}}} bearbeiten]</small>"
For editing any file ({{{1}}} is the full page name):
- Template:Edit (talk, backlinks, edit) containing
"<small class="editlink">[{{SERVER}}{{localurl:{{{1|{{NAMESPACE}}:{{PAGENAME}}}}}|action=edit}} +/-]</small>"
For a template containing only one paragraph or less, without links or images, one can also make the whole contents link to the edit page, see Template:ec (talk, backlinks, edit) containing "[{{SERVER}}{{localurl:{{{1}}}|action=edit}} {{{{{1}}}}}]".
This is e.g. convenient for editing an individual entry in a table, without having to search in the wikitext of the table.
Editing sections of included templates
This section appears both in Help:Section and in Help:Template.
The editing facilities can also be applied to a section of an included template. This section, Help:Editing sections of included templates, is an example.
For the purpose of section editing the extent of a section is governed by the headers in the calling page itself. It may consist of a part before the template tag, the template tag, and a part after the template tag, even if the template has sections.
It tends to be confusing if the extent of sections according to the system is different from what the rendered page suggests. To avoid this:
- if a template has headers, do not put any text before the first header
- in the calling page, start a new section after a template that itself has sections
It may be convenient, where suitable, to start a template with a section header, even if normally the contents of the template would not need a division into sections, and thus the template is only one section. The edit facilities for editing sections can then be used for editing the template from a page that includes it, without specially putting an edit link. This template is an example, it does not need a division into sections, but has a header at the top.
The __NOEDITSECTION__ tag in any template affects both that template, the pages it's included on, and any other templates included on the same page.
Usage
Templates are useful for any text for which one wants a copy in two or more pages, and there is no need for each copy to be edited independently, to adapt it to the page it is in. Since parameters can be used, versions may to that extent even be different, and parameter values can be edited independently for each. Templates are not only convenient, but they can also "force" a useful uniformity. See also advantages of subprograms.
Typical applications are:
- template messages such as w:en:Template:stub
- navigational templates such as w:en:Template:europe
- infoboxes, each time showing the same kind of information in the same format, but each time for a different case, using parameters, e.g. the w:en:Template:Infobox Countries.
- provide cross-language portability of texts which are largely internationally the same, but contain some standard terms different in each language; the standard terms are replaced by {{..}} referring to template pages which have the same name but localised content in each language. This is applied in Wiktionaries for names of languages, terms like "noun", etc.; it is also applied for taxoboxes, see e.g. w:en:Template:Familia and w:fr:Modèle:Familia.
- allow a composite image, composed of a table of images, to be specified by a template tag which itself has a corresponding table-like lay-out, see w:Template:Chess position and w:Template:Game of Go Position (the latter example also shows that the number of parameters a template can have is quite large, in this case 362). Newlines in parameter values provide the lay-out of the template tag, but they are not allowed in image names, therefore they are put within comment tags; alternatively, dummy parameters could be used on these positions.
Various combinations are possible. E.g., the last two could be combined, so that e.g. every language version of Wikipedia has the same Infobox Countries template (for each project a copy, because the template mechanism can not import across projects), which has parameters for the data, and refers to templates with translations of standard terms.
See also Help:Template names, variable names and parameters depending on a variable or parameter.
Navigational templates
A common, simple type of navigational template in a hierarchy of pages is one with the names, with links, of a parent page and child pages. It is placed on all the pages it lists. Thus a page that is not at the top or bottom of the hierarchy has two templates, one with its parent and siblings, and one with its children.
Variations also occur, such as pages having two parents, etc.
Self links do not give any complication: they are neatly displayed in bold and not as link. However, templates should have the correct page names and not rely on redirecting, since the feature does not work in that case. Also for a link to a section the self-link feature does not work.
A navigational template may also just allow going forward and backward in a linear sequence, e.g. en:Template:Pope. For the predecessor of the first and the successor of the last a message like "none" can be used. This is not applicable in the case of a cycle, such as the days of the week.
Composite pages
The wikitext of a page may (partly or fully) consist of tags for the inclusion of component pages. The "templates" are not necessarily in the template namespace, and may be more or less self-contained pages by themselves. An advantage of putting the components in the template namespace is that they are then included in the list of templates used on the composite page, all with links, on its edit page. On the other hand, the component page may, by itself, be of a nature that it belongs in e.g. the main namespace, while the prefix would suggest otherwise; also the prefix would clutter the pagename.
Examples are:
- Help:A simple composite example
- w:Wikipedia:Village pump with six component pages, e.g. w:Wikipedia:Village pump (technical)
- daily a page like w:en:Wikipedia:Votes for deletion/Log/2005 May 31 where each component page consists of the discussion on the deletion of one Wikipedia page, e.g. w:en:Wikipedia:Votes for deletion/Sp3tt (for this day there are 75 of such component pages)
- m:Meta:Translation/Coordination, mainly containing
- w:en::2005 English cricket season (1-14 June) (talk, backlinks, fw links, edit)
This allows the user the choice between viewing the component pages separately or combinedly. One may want to view a page separately if one has a slow connection; also sometimes people have sentimental reasons for having a separate page about a topic, e.g. a village. Viewing the combined page is much more convenient if there are many small component pages; even if a subbtopic page does not provide additional info, if it exists anyway, and is linked to, it is useful to display the content (making clear that the whole content is shown), it saves the trouble of checking the contents by following the link.
In the latter case the search function of the browser can be used for searching in the combined page. Similar to the section editing feature, it allows editing a component page; however, there is no possibility to have the combined wikitext in the edit box.
Edit history, recent changes, watching pages, and "what links here" work separately for the component pages and the composition page, not for the composite page. Related changes works for the component pages and for the composite page. Page protection can be set for selected component pages and for the composition page, not directly for the composite page.
The talk page of a composition page is used to talk about the composition and the page in general, and could in addition be a composite page of the talk pages of the component pages.
A composite page has an integrated TOC and section numbering; the numbering is not reset for each component page.
Editing a section of a component page can be done directly from the composite page, see editing sections of included templates. After saving, one ends up at the page for the component page to which the section belongs.
On projects with the interlanguage link feature the composite page shows the combined interlanguage links of all component pages, hence possibly multiple links for one language or even for one page.
For easy access to the component pages, links to them on the composite page (for example by self-links on the component pages) are convenient. Alternatively, access is through section editing, or, if the component pages are in the template namespace, through the list of templates called from the composite page, at its edit page.
Conversely, for easy access from a component page to the composite page(s) that call(s) it (if there are not too many of them) it is convenient to link the component page to them (on a composite page one becomes a self-link).
See also w:Wikipedia talk:Template namespace#transcluding prose.
Pages with a common section
A section on the relationship of the subjects A and B, or a subtopic equally relevant for A as for B, can be put both in page A and in page B, by making it a separate page C, called as a template from A and B.
Remarks:
- For readers reading both A and B, it is useful that the duplication is indicated by a message or a special lay-out; otherwise it is confusing and inconvenient. One can for example use Template:cs (talk, backlinks, edit): (This section appears in several articles.)
- After saving one ends up viewing the template page. For easy access to the calling pages it is convenient to link the called page to them (on a calling page one becomes a self-link). This may well be integrated in the message about the duplication. It is even more convenient than the two-step link as shown above.
- The section level of the embedded section(s) has to be the same in each embedding page. The same applies to lay-out and style.
- Pages like C can be put in
- the same namespace as A and B; advantage:
- the kind of content of C is the same as that of A and B
- the template namespace; advantages:
- C appears in the list of templates called from A and B, at their edit pages
- C by itself may not satisfy the standards for pages in the namespace of A and B, such as providing context (however, the message about the duplication explains it)
- the same namespace as A and B; advantage:
Examples:
- Help:Editing sections of included templates (talk, backlinks, fw links, edit)
- Help:Alphabetic order (talk, backlinks, fw links, edit)
For various remarks which also apply here, see also the previous section.
Repetition within a page
For a succession of similar pieces of content, as in a list, a computer program would use a loop. What comes closest in MediaWiki is putting the loop body in a template, and calling the template repeatedly, usually with a varying parameter value. This is somewhat primitive for a loop:
- instead of "for i=1 to 5" we need to enumerate the values 1, 2, 3, 4, 5; on the other hand, this gives the versatility to use just as easily less regular values such as de, en, fr (collection-controlled loop).
- repetition of code is minimized by the template, but the template call itself has to be repeated each time (but see also the next section)
Example:
- Template:List of Languages - the "loop body" is in Template:Lang def; compared with putting the content of the latter directly in the list the advantage is that the variable part (the value of "code") occurs once each time in the code, although it is used twice. This is important because the fixed part of the list item code can be copied while the variable part is typically inserted manually.
For repetition of the same text the loop body can be a parameter, e.g. Template:X5 (see list).
A double loop is achieved by a second template that repeatedly calls the first. Similarly for a triple loop, etc. See e.g. w:Template:Ld, w:Template:L2d, and w:Template:L3d.
An example where the same template is used for different loop levels is Template:Loop 2. Because the software has a built-in protection against infinite nesting (if there is, there will be an error e.g. Fatal error: Maximum execution time of 30 seconds exceeded in /w/includes/Parser.php on line 775), a redirect is used for each level. The number of levels that the template can handle is determined by the number of parameters specified in the two template calls it comprises (because going up a level requires an extra parameter) and the number of existing redirects.
Similarly Template:Lanlp 1 is used for both the inner and the outer of a double loop. Adding an item (here a language) adds to each row and also adds an extra row.
Providing effective repetition without repetition of similar template calls in the wikitext
A technique for repetition of similar template calls without actually putting this list in the wikitext is demonstrated in Template:foreach (talk, backlinks, edit) and w:en:Template:foreach (talk, backlinks, edit) (on which the version on Meta is based; it is similar but different on details), and a more primitive method described below.
Example (using Template:t2 containing "start-{{{1}}}-middle-{{{2}}}-end"):
{{foreach|call=t2|pc1=2|pc1v=constant|abc|def|ghi}} gives:
{{t2|1= abc|2|=|=|=}}{{t2|1=def|2|=|=|=}}{{t2|1=ghi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|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@ |2|=|=|=}}
Description of the old Template:List of template calls (talk, backlinks, edit):
For an arbitrary template with up to three nameless parameters, it is equivalent to calling the template repeatedly, with the first parameter varying, and the possible other parameters fixed: one specifies the name, the values of the fixed parameters, and the list of values the first parameter should have in consecutive template calls, with a sequential number each, and ending with "end". The technique requires redirects like Template:List of template calls 3, as many as the maximum number of repetitions.
If e.g. the second parameter varies, or two parameters, then a similar template can be made, but each version requires its own set of redirects.
Example (using Template:t2 containing "start-{{{1}}}-middle-{{{2}}}-end"):
{{List of template calls|t2|constant||abc|1|def|2|ghi|end|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||}}
gives:
start-abc-middle-constant-endstart-def-middle-constant-endstart-ghi-middle-constant-end
Compare {{foreach|call=t2|p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x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@|2|=|=|=}}{{x0|1=@ |2|=|=|=}}
The empty parameters are needed in accordance with the maximum number of parameters the repeated template can have (currently three) and the maximum number of repetitions. Putting more empty parameters than needed at the end does not matter, but the number of empty parameters in the beginning of the list should be correct.
Images in templates
New: In a template, image code parameters can contain template parameters, e.g.
{{timgi|wiki|50|small}} {{timgi|wiki|100|medium}} {{timgi|wiki|200|large}}
{{timg1|st|50|pqr}} {{timg1|st|100|st}}
using Template:Timgi containing "[[image:{{{1}}}.png|{{{2}}}px|{{{3}}} version]]" and Template:Timg1 containing "[[image:t{{{1}}}.png|thumb|left|{{{2}}}px|a{{{3}}}b]]"
give
Image:Wiki.png Image:Wiki.png Image:Wiki.png
For cases for which an image is not applicable or available, use a dummy image such as w:en:Image:No image.png.
For an image in a template that should be different for each page in which the template occurs, there are also the following possibilities:
- a parameter value can contain the whole image code: {{t|[[Image:Tst.png|50px|bullet]]}} gives start-Image:Tst.png-end
- in projects where external images can be embedded, the url of the image can be a parameter: {{t|http://meta.wikimedia.org/upload/2/27/Tst.png}} gives start-http://meta.wikimedia.org/upload/2/27/Tst.png-end
- Note that this does not work on projects hosted by Wikipedia, due to local restrictions about external references to embedded images (or objects or scripts or stylesheets): these images can only come from the local project (and will be served by the "http://upload.wikipedia.org/" base URL, the complete effective URL being computed and forced by the special [[Image:]] template), or alternatively the images can be imported automatically from the Wikipedia Commons project where they will be found if they are not present in the local project.
- Without this restriction, meant for security, it would be possible for any visitor to include the external reference of an image hosted somewhere else, that would either violate a copyright notice, or would contain in fact another object than an image, such as a malicious script that would be downloaded automatically by the browsers used by all visitors of the Wikipedia article that embeds such fake image.
- the image is given a name of the form prefix{{PAGENAME}}suffix (with a suffix, consisting of the file name extension and possibly more, and possibly also a prefix). See examples below. Note that there is little flexibility: changing the name of a page in which the template occurs requires uploading the image again, with the corresponding name.
Internal links
In the case of an internal link in a template with the target depending on a parameter, and in the case of a link with the target depending on a template, existence detection works as usual.
Examples:
- {{tli|insert in target|insert in label}} (using Template:tli containing "[[a{{{1}}}b|c{{{2}}}d]]") gives cinsert in labeld
- [[a{{tciit}}b|c{{tciil}}d]] (using Template:tciit containing "insert in target" and Template:tciil containing "insert in label") gives cinsert in labeld
- {{tli|insert also in target|insert in label}} (using Template:tli) gives cinsert in labeld (for the demo this page is supposed to be non-existing)
- [[a{{tciit}}e|c{{tciil}}d]] (using Template:tciit and Template:tciil) gives cinsert in labeld (for the demo this page is supposed to be non-existing)
- {{la|Help:Tabl|tabl}} (using Template:la containing "[[{{{1}}}a|{{{2}}}a]] [[{{{1}}}b|{{{2}}}b]] [[{{{1}}}c|{{{2}}}c]] [[{{{1}}}d|{{{2}}}d]] [[{{{1}}}e|{{{2}}}e]]") gives: tabla tablb tablc tabld table
Interwiki links
Templates can contain interwiki links; this normally means all pages using the template will have the interwiki, which is usually a bad thing unless some fancy footwork is done. To link just the templates across wikis, use the <noinclude> tag. For example:
<noinclude> [[de:Vorlage:Falscher Titel]] [[en:Template:Wrongtitle]] [[es:Plantilla:Título erróneo]] [[fr:Modèle:titre incorrect]] </noinclude>
Be careful when adding categories or interwikis within templates which are meant to be used inline, including within tables or lists: don't add newlines before <noinclude> or after </noinclude> because they will be kept in the resulting wiki code used to generate the page that references that template.
It is recommended to insert <noinclude>...</noinclude> at end of articles and templates, by first dropping the newline present at end of all existing articles and templates. The single newline that Wikipedia requires or adds automatically after </noinclude> is discarded when the template is instanciated for rendering the articles that include it.
See also below.
External links
With external link style much is possible. A blank space in a parameter value or template content that is substituted in a URL is not taken as ending the URL, but converted to %20.
Examples:
- {{tle|insert in target|insert in label}} (using Template:tle containing "[http://a{{{1}}}b c{{{2}}}d]")} gives in targetb cinsert in labeld
- {{tle2|insert in target}} (using Template:tle2 containing "http://a{{{1}}}b")} gives "http://ainsert in targetb"; note that brackets separated from the http:// are not recognized as belonging together:
- [{{tle2|insert in target}} label] gives in targetb label
- [{{tle2|insert in target}}] gives in targetb
- {{tle3|insert in target}} (using Template:tle3 containing "[http://a{{{1}}}b]")} gives in targetb
- [http://a{{tciit}}b c{{tciil}}d] gives in targetb cinsert in labeld
- http://a{{tciit}}b gives "http://ainsert in targetb"
- [http://a{{tciit}}b] gives in targetb
However, a URL can not be composed of:
- a first part in a parameter and a second part added by the template (although we have seen above that reversed it works: a second part in a parameter and a first part prefixed by the template)
- a first part in a template and a second part after the template (although we have seen above that reversed it works: the second part in a template and the first part before the template)
Example of first restriction:
- {{tae|http://www.}} (using Template:tae containing "{{{1}}}add at the end")} gives http://www.add at the end
Examples of second restriction:
- [{{th}}add at the end] (using Template:th containing "http://www.")} gives at the end
- "{{th}}add a