Help:Templates

From MeritBadgeDotOrg

(Difference between revisions)
Jump to: navigation, search
m
Current revision (20:56, May 14, 2012) (edit) (undo)
m (Correct syntax for link: Wikipedia:Template namespace.)
 
(15 intermediate revisions not shown.)
Line 1: Line 1:
-
{{Workpage}}
 
==An introduction to templates==
==An introduction to templates==
-
In MediaWiki, a '''template''' is a page which can be inserted into another page via a process called [[transclusion|transclusion]].
+
In MediaWiki, a '''template''' is a page which can be inserted into another page via a process called [http://en.wikipedia.org/wiki/Wikipedia:Transclusion ''transclusion''].
'''''Except where otherwise specified herein, the following resources should be referenced for guidance in creating templates on MeritBadgeDotOrg:'''''
'''''Except where otherwise specified herein, the following resources should be referenced for guidance in creating templates on MeritBadgeDotOrg:'''''
-
*'''[http://en.wikipedia.org/wiki/Help:Template Wikipedia:Help:Templates]'''
+
*Local guidance and resources found on MeritBadgeDotOrg...
-
*'''[http://en.wikipedia.org/wiki/Help:Advanced_templates Wikipedia:Help:Advanced templates]''', and
+
**'''''[[Help:Templates]]''''' — ''(You are here.)''
-
*'''[http://en.wikipedia.org/wiki/Help:A_quick_guide_to_templates Wikipedia:A quick guide to templates]'''
+
***'''''[[Help:Templates/Template documentation]]'''''
 +
***'''''[[Help:Templates/Template doc page pattern]]'''''
-
The '''template namespace''' is the [[Help:Namespace|namespace]] with prefix "'''Template:'''". A page in this namespace is called a '''template'''. The contents of such a page is designed to be useful for insertion in other pages ([[en:transclusion|transclusion]], creating a [[w:compound document|compound document]]).
+
*Resources found on Wikipedia, MediaWiki, or other Wiki Foundation web sites...
 +
**'''[http://en.wikipedia.org/wiki/Wikipedia:Template_namespace Wikipedia:Template namespace]'''
 +
**'''[http://en.wikipedia.org/Help:Template Wikipedia Help:Templates]'''
 +
**'''[http://en.wikipedia.org/Help:Advanced_templates Wikipedia Help:Advanced templates]'''
 +
**'''[http://en.wikipedia.org/Help:A_quick_guide_to_templates Wikipedia Help:A quick guide to templates]'''
 +
**'''[http://mediawiki.org/wiki/Help:Templates MediaWiki Help:Templates]'''
 +
 
 +
The '''template namespace''' is the [[Help:Namespaces|namespace]] with prefix "'''Template:'''". A page in this namespace is called a '''template'''. The contents of such a page is designed to be useful for insertion in other pages ([http://en.wikipedia.org/wiki/Transclusion transclusion], creating a [http://en.wikipedia.org/wiki/Compound_document compound document]).
===Usage===
===Usage===
Line 16: Line 23:
===Ambiguity of a reference to "this page"===
===Ambiguity of a reference to "this page"===
If a page is included in another page, a reference to "this page" on the included page is ambiguous. Use noinclude or includeonly tags depending on what is meant. Alternatively, mention the page name explicitly, without using <nowiki>{{</nowiki>PAGENAME}}.
If a page is included in another page, a reference to "this page" on the included page is ambiguous. Use noinclude or includeonly tags depending on what is meant. Alternatively, mention the page name explicitly, without using <nowiki>{{</nowiki>PAGENAME}}.
 +
 +
==Location==
 +
*All MeritBadgeDotOrg templates must reside in the "Template:" namespace.
 +
*Personal user templates, however, must reside in '''<nowiki>User:"Username"/Template/"Template name"</nowiki>'''
===Prefixing templates from "external" wikia===
===Prefixing templates from "external" wikia===
-
Templates on the central Wikia work in the separate Wikia projects, provided that the prefix "wikia:" is used, see <span class="plainlinks">[http://www.wikia.com/wiki/Help:Shared_templates shared templates on wikia]</span>. (Please note that these external Wikia projects are NOT hosted and managed by the Wikimedia Foundation.) '''--Please do not attempt this! Templates running on MeritBadgeDotOrg ''must'' reside on MeritBadgeDotOrg.'''
+
Templates on the central Wikia work in the separate Wikia projects, provided that the prefix "wikia:" is used, see <span class="plainlinks">[http://www.wikia.com/wiki/Help:Shared_templates shared templates on wikia]</span>. (Please note that these external Wikia projects are NOT hosted and managed by the Wikimedia Foundation.) '''--Please do not attempt this! All templates running on MeritBadgeDotOrg ''must'' reside on MeritBadgeDotOrg.'''
-
===Transclusitons in templates===
+
===Transclustions in templates===
Transclusion across projects, hence changing contents from a central place, is only possible:
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 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. '''--Porting images from WikiCommons into templates on MeritBadgeDotOrg is perfectly fine.'''
+
*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.''' --Porting images from WikiCommons into templates on MeritBadgeDotOrg is perfectly acceptable.'''
-
===Location===
+
==Template substitution==
-
*All MeritBadgeDotOrg templates must reside in the "Template:" namespace.
+
{{Help:Template_substitution}}{{clear}}
-
*Personal user templates, however, should reside in '''<nowiki>User:"Username"/Template/"Template name"</nowiki>'''
+
==Template Talk==
==Template Talk==
Line 36: Line 46:
*The converse is <includeonly>. Text between <includeonly> and </includeonly></nowiki> will be processed and displayed only when the page is being included.
*The converse is <includeonly>. Text between <includeonly> and </includeonly></nowiki> will be processed and displayed only when the page is being included.
-
===Tagging templates===
+
===Tagging Templates===
For the time being, all templates on MeritBadgeDotOrg should include the following tag (preferably, at the bottom of the template):
For the time being, all templates on MeritBadgeDotOrg should include the following tag (preferably, at the bottom of the template):
Line 56: Line 66:
==See also==
==See also==
-
*[[m:Help:Advanced templates|Help:Advanced templates]]<!-- m: not directly portable due to examples -->
+
===Internal links===
-
*[[Help:Template documentation]]
+
*[http://meritbadge.org/wiki/index.php?title=Special%3AAllpages&from=&namespace=10 List of all templates on the MeritBadgeDotOrg Wiki]
-
*[[m:Help:MediaWiki help policy|MediaWiki help templates]]
+
 
-
*[{{fullurl:Special:Allpages|namespace=10}} List of all templates on this server]
+
===External links===
 +
*[http://en.wikipedia.org/wiki/Wikipedia:Template_messages Wikipedia:Template messages]
-
*[http://www.mediawiki.org/wiki/Help:Templates MediaWiki:Help:Templates]
+
[[Category:Help|{{PAGENAME}}]]

Current revision

Contents

An introduction to templates

In MediaWiki, a template is a page which can be inserted into another page via a process called transclusion.

Except where otherwise specified herein, the following resources should be referenced for guidance in creating templates on MeritBadgeDotOrg:

The template namespace is the namespace with prefix "Template:". A page in this namespace is called a template. The contents of such a page is designed to be useful for insertion in other pages (transclusion, creating a compound document).

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.

Ambiguity of a reference to "this page"

If a page is included in another page, a reference to "this page" on the included page is ambiguous. Use noinclude or includeonly tags depending on what is meant. Alternatively, mention the page name explicitly, without using {{PAGENAME}}.

Location

  • All MeritBadgeDotOrg templates must reside in the "Template:" namespace.
  • Personal user templates, however, must reside in User:"Username"/Template/"Template name"

Prefixing templates from "external" wikia

Templates on the central Wikia work in the separate Wikia projects, provided that the prefix "wikia:" is used, see shared templates on wikia. (Please note that these external Wikia projects are NOT hosted and managed by the Wikimedia Foundation.) --Please do not attempt this! All templates running on MeritBadgeDotOrg must reside on MeritBadgeDotOrg.

Transclustions in templates

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. --Porting images from WikiCommons into templates on MeritBadgeDotOrg is perfectly acceptable.

Template substitution

Substitution is the automatic conversion of wikitext of a page when the page is saved, in that the wikitext refers to one or more templates, variables, or parser functions.

In the case of template substitution, the template call is replaced by the template content with substitution of the parameters. Thus, the template is used as macro and the page is macro expanded when the page is saved rather than, as usually happens, when the page is viewed.

In other words, when you "subst:" a template... the entire template is not only called, but saved, to the page you are editing, using the specific variables you input.

See also

External links

Template Talk

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.

Noinclude and includeonly

  • Anything between <noinclude> and </noinclude> will be processed and displayed only when the page is being viewed directly; it will not be included or substituted. *The converse is <includeonly>. Text between <includeonly> and </includeonly> will be processed and displayed only when the page is being included.

Tagging Templates

For the time being, all templates on MeritBadgeDotOrg should include the following tag (preferably, at the bottom of the template):

<<noinclude>[[Category:Templates|{{PAGENAME}}]]</noinclude>

This will add all templates to the template category.

If you are interested in helping out with or colaborating on Templates, please do so on the Help_talk:Templates page.

Tagging Shortcuts

The Shortcut template also contains the following:

<<includeonly>[[Category:Shortcuts|{{PAGENAME}}]]</includeonly>

This will add all shortcuts (that reference the Shortcut template) to the Shortcut category.

If you are interested in helping out with or colaborating on Shortcuts, please do so on the Help_talk:Shortcuts page.

See also

Internal links

External links

Personal tools
language