Leading a team online

From apppm
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Lua|icononly=on|Module:Main}} When a Wikipedia article is large, it is often written in summary style. This [[W...")
 
 
Line 1: Line 1:
{{Lua|icononly=on|Module:Main}}
+
{{Wikipedia how to|sort-by=Templates, A quick guide to}}
 +
This is a quick '''overview of templates'''. Full details can be found in '''[[Help:Template]]''' and '''[[m:Help:Advanced templates]]'''.
  
When a [[Wikipedia:What is an article|Wikipedia article]] is large, it is often written in [[Wikipedia:summary style|summary style]]. This [[Wikipedia:Template messages|template]] is used after the heading of the summary, to link to the sub-article that has been summarized. For [[Help:Category|Category namespace]], please use '''{{tl|Cat main}}''' instead.
+
[[Image:Sandfoermchen-3.jpg|right|300px|thumb|A template allows you to reproduce infinite content.]]
 +
Templates are pages in the [[Wikipedia:Template namespace|template namespace]]. This means any page whose title begins with "Template:", such as "[[Template:foo]]", can be used as a template. The content of a template titled Template:templatename, can be added to a page by typing <code><nowiki>{{templatename}}</nowiki></code> while editing the page. When the page is later viewed, <code><nowiki>{{templatename}}</nowiki></code> is replaced by the content of the page "Template:templatename". If the page "Template:templatename" is later altered, all the pages with <code><nowiki>{{templatename}}</nowiki></code> in them will change automatically.
  
Use of this template should be restricted to the purposes described above. It is '''not''' to be used as a substitute for inline links or {{tl|Further}} template. The latter is used when the section expounds a specific aspect of the topic instead of summarizing its article. For example, in [[phthalate]], the template under the "Endocrine disruptor" section should '''not''' be {{tlf|Main|Endocrine disruptor}}, because the section specifically deals with phthalate as an endocrine disruptor and not endocrine disruptors in general.
+
Among other things, templates are used to add recurring messages to pages in a consistent way, to add [[Wikipedia:Glossary#Boilerplate text|boilerplate]] messages, and to create navigational boxes.
  
{{TOC limit}}
+
When a template is automatically expanded and appears on a page, it is said to be "[[Wikipedia:Transclusion|transcluded]]".
  
== Usage ==
+
Templates are documented (or should be) at their pages. Thus if you want to know how to use a template whose name is "foo" (perhaps because you've seen <code><nowiki>{{foo|...}}</nowiki></code> in the source of an article), then go to "Template:foo". (The documentation itself will usually be located at "Template:foo/doc", but will be transcluded onto the "Template:foo" page).
; Basic usage: {{tlf|main|''page''}}
+
; All parameters: {{((}}main | ''page1'' | ''page2'' | ''page3'' | ... | l1 = ''label1'' | l2 = ''label2'' | l3 = ''label3'' | ... | selfref = ''yes''{{))}}
+
  
== Parameters ==
+
==Creating, editing and using templates==
 +
You start a new template in the same way you would [[Wikipedia:Starting an article|start an article page]]. The only difference is that its title must start with <code>Template:</code>.
  
* <code>1</code>, <code>2</code>, <code>3</code>, ... - the pages to link to. If no page names are specified, the current page name is used instead (without the [[WP:NS|namespace]] prefix). Categories and files are automatically escaped with the [[Help:Colon trick|colon trick]], and links to sections are automatically formatted as ''page § section'', rather than the MediaWiki default of ''page#section''.
+
Once you have made the template, for example ''Template:templatename'', you can add <code><nowiki>{{</nowiki>''templatename''<nowiki>}}</nowiki></code> to the pages you want to use it on. Every page using this template uses the same [[boilerplate (text)|boilerplate]] text, each time a user visits it. When the template is updated, all pages containing the template tag are automatically updated.
* <code>l1</code>, <code>l2</code>, <code>l3</code>, ...; optional labels for each of the pages to link to (this is for articles where a piped link would be used). Note that the extra parameters use a lower case 'L', for example, <code>l1</code>, <u>not</u> <code>11</code>.
+
* <code>selfref</code> - if set to "yes", "y", "true" or "1", adds the CSS class "selfref". This is used to denote self-references to Wikipedia. See [[Template:Selfref]] for more information. This is only necessary in articles and other content (e.g. templates) that will appear in articles, and need not be added for uses of this template on <code>Wikipedia:</code> namespace pages.
+
  
== Examples ==
+
Alternatively, you can add <code><nowiki>{{</nowiki>subst:''templatename''<nowiki>}}</nowiki></code> to the pages you want to use the boilerplate text on. The system fetches a one-time copy of the template text, and '''[[Wikipedia:Substitution|substitutes]]''' it into the page, in place of the template tag. If anyone edits the template afterwards, pages that used the <code>subst:</code> keyword do '''not update'''. Sometimes that is what you want.
  
* <code><nowiki>{{main|Article}}</nowiki></code> &rarr; {{main|Article}}
+
If the template you want to edit looks like <code><nowiki>{{foo}}</nowiki></code>, you would go to [[Template:foo]] to edit it. To get there, type "Template:foo" in the search box (see [[Help:Searching|search]]), or make a wikilink like <code><nowiki>[[Template:foo]]</nowiki></code> somewhere, such as in the [[{{ns:4}}:sandbox|sandbox]], and click on it.
* <code><nowiki>{{main|Article#Section}}</nowiki></code> &rarr; {{main|Article#Section}}
+
* <code><nowiki>{{main|Article#Section|l1=Custom section label}}</nowiki></code> &rarr; {{main|Article#Section|l1=Custom section label}}
+
* <code><nowiki>{{main|Article1|Article2|Article3}}</nowiki></code> &rarr; {{main|Article1|Article2|Article3}}
+
* <code><nowiki>{{main|Article1|l1=Custom label 1|Article2|l2=Custom label 2}}</nowiki></code> &rarr; {{main|Article1|l1=Custom label 1|Article2|l2=Custom label 2}}
+
* <code><nowiki>{{main|(15760) 1992 QB1|l1={{mp|(15760) 1992 QB|1}}}}</nowiki></code> &rarr; {{main|(15760) 1992 QB1|l1={{mp|(15760) 1992 QB|1}}}}
+
  
{{Hatnote templates documentation}}
+
Once you are there, just click "edit" or "edit this page" and edit it in the same way you would any other page. You can add anything you would add to a normal page, including text, images and other templates. Please be aware that your edit might affect many pages, so be cautious.
{{Collapse top|TemplateData}}
+
{{TemplateDataHeader}}
+
<templatedata>
+
{
+
"description": "This template is used after the heading of a section, to link to a sub-article (or sub-articles) that is entirely about the topic of the section. The template will display, in italics, \"Main article: Article 1, Article 2 and Article 3\"",
+
"params": {
+
"1": {
+
"label": "Page 1",
+
"description": "The name of the first page that you want to link to. If this is not specified, the current page name (with no namespace prefix) is used instead. ",
+
"type": "string/line",
+
"required": false
+
},
+
"2": {
+
"label": "Page 2",
+
"description": "The name of the second page that you want to link to.",
+
"type": "string/line",
+
"required": false
+
},
+
"3": {
+
"label": "Page 3",
+
"description": "The name of the third page that you want to link to. More pages can be added using the parameters \"4\", \"5\", \"6\", etc.",
+
"type": "string/line",
+
"required": false
+
},
+
"l1": {
+
"type": "string/line",
+
"label": "Label 1",
+
"description": "What the first linked page is to be displayed as."
+
},
+
"l2": {
+
"label": "Label 2",
+
"description": "What the second linked page is to be displayed as.",
+
"type": "string/line"
+
},
+
"l3": {
+
"label": "Label 3",
+
"description": "What the third linked page is to be displayed as. Other labels can be added by using increasing numbers (starting with \"l4\" for page 4) as parameter names.",
+
"type": "string/line"
+
},
+
"selfref": {
+
"type": "string/line",
+
"label": "Self reference",
+
"description": "Set to \"yes\" if the template is a self-reference to Wikipedia that would not make sense on mirrors or forks of the Wikipedia site."
+
}
+
}
+
}
+
</templatedata>
+
{{Collapse bottom}}
+
  
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
+
===Parameters===
<!-- Categories go here and interwikis go in Wikidata. -->
+
Templates can have parameters. Instead of just the template name, like <code><nowiki>{{foo}}</nowiki></code>, a template with parameters will have additional text, separated by [[vertical bar]]s (|), e.g. <code><nowiki>{{foo|July|lc=yes}}</nowiki></code>. Here <code>July</code> is the value of the first unnamed parameter; <code>yes</code> is the value of the named parameter <code>lc</code>. Writing the template page for a template with parameters is more complicated than for a template with no parameters. See [[Help:Template]].
[[Category:Cross-reference templates]]
+
[[Category:Exclude in print]]
+
[[Category:Hatnote templates]]
+
[[Category:List templates]]
+
[[Category:Wikipedia page-section templates]]
+
  
}}</includeonly>
+
== Template link template==
 +
The [[template:template link|'''template link''' template]] is a simple [[w:Macro (computer science)|macro]] [[m:Help:template|template]] used to display a template name as a link surrounded by braces, thus showing how the template name would be used in code. Its primary use is in instruction and documentation. A short example is that the code:
 +
 
 +
::<code><nowiki>{{tl|Example}}</nowiki></code>
 +
:generates
 +
::{{tl|Example}}
 +
 
 +
==FAQ==
 +
;How can I find out how to use an existing template? : To see the documentation for the template whose name is "foo", go to "Template:foo".
 +
;Can I use a template in more than one project? : No, if you want to use it on two different language Wikipedias, for example, you would need to create it twice.
 +
; Are templates case-sensitive? : Yes, except usually the first letter.
 +
; Can I add parameters? : Yes, see [[Help:Template]] for instructions.
 +
; How many templates can I use in a page? : A lot, but it depends on how they work. (In older versions you could not use the ''same one'' more than 5 times). There is a limit on the number of template expansions allowed during the creation of a page. If the templates you put on the page use other templates when they are expanded, it is possible to exceed the limit. See [[WP:UNNEST]].
 +
; I edited the template, so why didn't the page it is used on change? : Wikipedia and your computer both store ''[[Web cache|caches]]''&nbsp;– or saved copies&nbsp;– and don't always show you an updated page. First, try to [[WP:BYPASS|bypass your browser's cache]] by pressing ⌘R or Ctrl and F5. If that fails, you need to [[WP:PURGE|purge]] the page's cache (which can be done several different ways). Perhaps the easiest way to do this is by clicking '''edit''' on the page in which the template appears, and then clicking on '''Save page''' without having changed anything&nbsp;– there is no need to fill in the ''Summary'' field since there will not be any ''history'' of this as a change generated.
 +
; Can I move a template to a new name? : Yes, this works in exactly the same way as normal [[Help:Moving a page|page moves]]. When a page called for inclusion is a redirect page, the redirect target is included instead.
 +
; Can I use a template within a template? : Yes.
 +
;How do I add a new template?: You start a new template in the same way you would start a normal page. The only difference is that its title must start with {{code|Template:}}. Don't forget to document it so that other editors can use it!
 +
; Where is the manual for the programming language used to write templates?: The language inside templates is the same language as regular wiki markup, but template writers tend to use the more complex available functions such as #if: statements. See Wikipedia's [[Help:Template]], Wikimedia's [[mw:Help:Template]], and all of the "advanced functioning" help pages listed toward the bottom of [[mw:Help:Template#Links to other help pages]].
 +
 
 +
==Examples==
 +
*[[w:en:Template:stub]]: an often used message (at English Wikipedia).
 +
<!-- *[[w:en:Template:europe]]: a navigational template -->
 +
*[[w:en:Template:Biological classification]]: a template with parameters (at English Wikipedia).
 +
*[[b:en:Template:GeneralChemTOC]]: a horizontal menu bar (at English [[Wikibooks]]).
 +
*[[w:en:Template:Underwater work]]: a template as a simple table with a picture (at English Wikipedia).
 +
 
 +
== Wikipedia-specific help ==
 +
*[[Help:Template]] (more details)
 +
*[[m:Help:Templates]] (details from [[Wikimedia]])
 +
*[[m:Help:Advanced templates]] (advanced details from Wikimedia)
 +
*[[Wikipedia:Template namespace]] (the usual [[Wikipedia:Namespace|namespace]] for templates)
 +
*[[Wikipedia:Transclusion]] (transcluding templates)
 +
*[[Wikipedia:Substitution]] (substituting templates)
 +
*[[Wikipedia:Template messages]] (categorised list of links to available templates)
 +
 
 +
{{Help navigation}}
 +
{{Wikipedia technical help|collapsed}}
 +
[[Category:Wikipedia templates| ]]

Latest revision as of 10:02, 18 September 2015

Template:Wikipedia how to This is a quick overview of templates. Full details can be found in Help:Template and m:Help:Advanced templates.

File:Sandfoermchen-3.jpg
A template allows you to reproduce infinite content.

Templates are pages in the template namespace. This means any page whose title begins with "Template:", such as "Template:foo", can be used as a template. The content of a template titled Template:templatename, can be added to a page by typing {{templatename}} while editing the page. When the page is later viewed, {{templatename}} is replaced by the content of the page "Template:templatename". If the page "Template:templatename" is later altered, all the pages with {{templatename}} in them will change automatically.

Among other things, templates are used to add recurring messages to pages in a consistent way, to add boilerplate messages, and to create navigational boxes.

When a template is automatically expanded and appears on a page, it is said to be "transcluded".

Templates are documented (or should be) at their pages. Thus if you want to know how to use a template whose name is "foo" (perhaps because you've seen {{foo|...}} in the source of an article), then go to "Template:foo". (The documentation itself will usually be located at "Template:foo/doc", but will be transcluded onto the "Template:foo" page).

Contents

[edit] Creating, editing and using templates

You start a new template in the same way you would start an article page. The only difference is that its title must start with Template:.

Once you have made the template, for example Template:templatename, you can add {{templatename}} to the pages you want to use it on. Every page using this template uses the same boilerplate text, each time a user visits it. When the template is updated, all pages containing the template tag are automatically updated.

Alternatively, you can add {{subst:templatename}} to the pages you want to use the boilerplate text on. The system fetches a one-time copy of the template text, and substitutes it into the page, in place of the template tag. If anyone edits the template afterwards, pages that used the subst: keyword do not update. Sometimes that is what you want.

If the template you want to edit looks like {{foo}}, you would go to Template:foo to edit it. To get there, type "Template:foo" in the search box (see search), or make a wikilink like [[Template:foo]] somewhere, such as in the sandbox, and click on it.

Once you are there, just click "edit" or "edit this page" and edit it in the same way you would any other page. You can add anything you would add to a normal page, including text, images and other templates. Please be aware that your edit might affect many pages, so be cautious.

[edit] Parameters

Templates can have parameters. Instead of just the template name, like {{foo}}, a template with parameters will have additional text, separated by vertical bars (|), e.g. {{foo|July|lc=yes}}. Here July is the value of the first unnamed parameter; yes is the value of the named parameter lc. Writing the template page for a template with parameters is more complicated than for a template with no parameters. See Help:Template.

[edit] Template link template

The template link template is a simple macro template used to display a template name as a link surrounded by braces, thus showing how the template name would be used in code. Its primary use is in instruction and documentation. A short example is that the code:

{{tl|Example}}
generates
Template:Tl

[edit] FAQ

How can I find out how to use an existing template? 
To see the documentation for the template whose name is "foo", go to "Template:foo".
Can I use a template in more than one project? 
No, if you want to use it on two different language Wikipedias, for example, you would need to create it twice.
Are templates case-sensitive? 
Yes, except usually the first letter.
Can I add parameters? 
Yes, see Help:Template for instructions.
How many templates can I use in a page? 
A lot, but it depends on how they work. (In older versions you could not use the same one more than 5 times). There is a limit on the number of template expansions allowed during the creation of a page. If the templates you put on the page use other templates when they are expanded, it is possible to exceed the limit. See WP:UNNEST.
I edited the template, so why didn't the page it is used on change? 
Wikipedia and your computer both store caches – or saved copies – and don't always show you an updated page. First, try to bypass your browser's cache by pressing ⌘R or Ctrl and F5. If that fails, you need to purge the page's cache (which can be done several different ways). Perhaps the easiest way to do this is by clicking edit on the page in which the template appears, and then clicking on Save page without having changed anything – there is no need to fill in the Summary field since there will not be any history of this as a change generated.
Can I move a template to a new name? 
Yes, this works in exactly the same way as normal page moves. When a page called for inclusion is a redirect page, the redirect target is included instead.
Can I use a template within a template? 
Yes.
How do I add a new template?
You start a new template in the same way you would start a normal page. The only difference is that its title must start with Template:Code. Don't forget to document it so that other editors can use it!
Where is the manual for the programming language used to write templates?
The language inside templates is the same language as regular wiki markup, but template writers tend to use the more complex available functions such as #if: statements. See Wikipedia's Help:Template, Wikimedia's mw:Help:Template, and all of the "advanced functioning" help pages listed toward the bottom of mw:Help:Template#Links to other help pages.

[edit] Examples

[edit] Wikipedia-specific help

Template:Help navigation Template:Wikipedia technical help

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox