Difference between revisions of "Help:Templates"

→‎Other Templates: added a description of source for quotes
m (Fix)
(→‎Other Templates: added a description of source for quotes)
 
(20 intermediate revisions by 6 users not shown)
{{HelpToC}}
'''Templates''' make more complicated and repetitive editing tricks easier to do. This page will explain how to create and use them. For more details, see Wikipedia's Help page on [https://en.m.wikipedia.org/wiki/Help:Template Templates].
 
Most templates that you may need to use already exist, so let's talk about ''using them'' first.
 
Templates are enclosed by double curly braces (<code>{{</code> and <code>}}</code>). The ''template name'' comes first, followed by ''parameters'', all separated by vertical bars (<code>|</code>). It looks something like this: <code><nowiki>{{name|param1|param2|param3}}</nowiki></code>.
 
Note that some templates are entered in a single line of text, like the example above. This is common for reference templates and those which don't require any parameters. However, it is not uncommon for templates to span multiple lines, for the sake of clarity. Something more like:
 
<pre style="white-space:pre-wrap; width:100px">
 
=== Parameters ===
There are two kinds of parameters: '''named''' and '''unnamed'''. Named parameters are identified by the name of the parameter while unnamed parameters are identified simply by the order they appear.
 
;Named Parameters
: ''Named parameters'' require the parameter name and an equals sign (<code>=</code>) followed by your input. If <code>param1</code> is a named parameter of {{t|example}}, and you want the input to be "Mistborn", then you will enter <code><nowiki>{{example|param1=Mistborn}}</nowiki></code>.
 
;Unnamed Parameters
: ''Unnamed parameters'' should be completely replaced by your input. If <code>param1</code> is an unnamed parameter of {{t|example}}, and you want the input to be "Mistborn", then you will enter <code><nowiki>{{example|Mistborn}}</nowiki></code>.
 
=== Example ===
{{character
|image=Kelsier.jpg
|abilities=[[Allomancy|Mistborn]]
|image-artist=[[Kit Buss]]
|abilities=[[Mistborn]]
|spouse=[[Mare]]
|siblings=[[Marsh]]
|name=Kelsier
|image=Kelsier.jpg
|abilities=[[Allomancy|Mistborn]]
|image-artist=[[Kit Buss]]
|abilities=[[Mistborn]]
|spouse=[[Mare]]
|siblings=[[Marsh]]
 
=== Information Boxes ===
Called '''infoboxes''' for short, these templates create the tables at the upper right hand corner of articles. They display important facts and details which are common to articles of the same category. Infoboxes are ''placed at the start of the article''. There are infobox templates for all of the high level content categories, and a few others that are more specific. Common examples include {{t|book}}, {{t|character}}, {{t|magic system}}, and {{t|placelocation}}.
 
For more detailed help on infoboxes in general see [[:Help: Infoboxes]] and for a full list of infobox templates, see [[:Category: Infoboxes]].
 
=== Navigation Boxes ===
 
;{{t|move}}
: Requests that an administrator move the page (change the title). An unnamed parameter may be included to indicate which page it should be moved ''to''.
 
;Quality Tags
: Quality tags are simple templates that indicate the level of completion/quality of an article and categorize it accordingly. These are discussed in detail on the [[:Help:Categories#Quality_Tags|Help:Categories]] page and include {{t|stub}}, {{t|partial}}, and {{t|complete}}
 
=== Reference Templates ===
Reference templates are used to cite the source of information in an article. They create a superscript, number that links to the footnotes in the "Notes" section, where the full reference is provided. For more on reference templates, see [[:Help:References]].
 
=== Link Macros ===
Link macros are templates which link to something that's related to the input. They often categorize the article as well. For a full list of link macros, see [[:Category:Link_macrosLink macros]].
 
=== Editorial Notations ===
 
;{{t|quote}}
: Use {{t|quote}} to highlight some text as a quote. Use <code><nowiki>{{quote|TEXT|SOURCE}}</nowiki></code>, where <code>TEXT</code> is the quote itself and <code>SOURCE</code> is the source of the quote (typically the name of the speaker or a short description of the context, followed by a [[:Help:References|reference]]). <code><nowiki>{{quote|Do or do not. There is no try.|Yoda}}</nowiki></code> produces:
: {{quote|Do or do not. There is no try.|Yoda}}
 
;{{t|sidequote}}
: {{sidequote|Do or do not. There is no try.|Yoda|side=right|size=300px}} Use {{t|sidequote}} to place a quote on one side of the page, with text floating around it. Use <code><nowiki>{{sidequote|TEXT|SOURCE|POSITION|WIDTH}}</nowiki></code>, where <code>TEXT</code> is the quote itself, <code>SOURCE</code> is the source of the quote, <code>POSITION</code> is the alignment of the quote (<code>left</code> or <code>right</code>), and <code>WIDTH</code> is some number followed by "px", to specify the width of the quote in pixels. When placed at the top of this paragraph, <code><nowiki>{{sidequote|Do or do not. There is no try.|Yoda|side=right|size=300px}}</nowiki></code> produces the quote to the right.
 
;{{t|for}}
: This template provides a quick and clean way to refer to other articles. It generally takes one unnamed parameter, <code>{{{1}}}</code>, as input. By default, it returns "For more information, see <code>{{{1}}}</code>", where <code>{{{1}}}</code> is a link to the referenced article. A second unnamed parameter will replace "more information" and a third will replace the text which refers to the linked article. For example, <code><nowiki>{{for|cosmere|aoodles lotof moreinformation|this page about the cosmere}}</nowiki></code> produces:
: {{for|cosmere|aoodles lotof moreinformation|this page about the cosmere}}
 
== Template Pages ==
 
=== Parser Functions ===
There are a number of functions that can be used to generate different results based on the input provided. For an extensive list, see [https://www.mediawiki.org/wiki/Help:Extension:ParserFunctions MediaWiki's Parser Functions] page. Here are some of the basics:
 
;UpercasingUppercasing Text
: This function converts a string of text to all uppercase.
: ''Use:'' <code><nowiki>{{uc: TEXT}}</nowiki></code>, where <code>TEXT</code> is the text to be converted.
: This function performs a series of string compares until a "true" result is found.
: ''Use:'' <code><nowiki>{{#switch: X|A=Result1|B=Result2|C=Result3|etc.|Default}}</nowiki></code>, where <code>X</code> is compared to <code>A</code>, <code>B</code>, and so on. The first match provides the corresponding result. A final, default result may be provided in case no match is found.
: ''Example:'' <code><nowiki>{{#switch: cat|dog=bark|cat=meow|growl}}</nowiki></code> produces <code>meow</code> and <code><nowiki>{{#switch: bear|dog=bark|cat=meow|growl}}</nowiki></code> produces <code>growl</code>.
 
=== System Variables ===
There are a few system variables which provide different values as needed. These are given in all caps between double curly braces. For an extensive list, see [https://www.mediawiki.org/wiki/Help:Magic_words MediaWiki's Magic Words] page. The two most common are:
 
;Pagename
Comments inside of <code><nowiki><includeonly></nowiki></code> tags can be provided between <code><nowiki><!--</nowiki></code> and <code><nowiki>--></nowiki></code>.
 
Note: You might see a lot of these in existing templates, at the beginning and end of each line. White space can do strange things in templates, and so it is best to eliminate unnecessary white space by putting it inside of comments. One notable exception is inside tables, between the <code>|-</code> and the first cell <code>|</code>, which means the infobox {{t|row/kv}} (et al) can be nicely spaced without consequence.
 
 
[[Category: Help]]
{{help
|title=New Editor's Guide
|prev=[[Help:Categories|Categories]]
|this=Templates
|next=[[Help:What now?|What now?]]
}}
Editors, Keepers
2,004

edits