Difference between revisions of "Help:Templates"

→‎Other Templates: added a description of source for quotes
(→‎Other Templates: added a description of source for quotes)
 
(37 intermediate revisions by 8 users not shown)
{{HelpToC}}
So you want to know how to use templates? You're in the right place. {{cat|templates|*}}{{cat|Help}}
'''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].
 
== Using Templates ==
First off, to use a template you insert it's name in <code><nowiki>{{curly brackets}}</nowiki></code>.
Most templates that you may need to use already exist, so let's talk about ''using them'' first.
Most templates ask for parameters which are passed as so: <code><nowiki>{{eg|first argument|second|foo=named argument}}</nowiki></code>.
You see the <code>foo=</code> part? That's a named argument, and is used for special parameters, such as the [[Template:Infobox|infobox]] field names.
 
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>.
== Information boxes ==
The {{t|Infobox}} templates are shown at the right-hand corner of articles, the display important facts and statistics which are common to group of articles. They are placed at the start of the article, and show a list of information down the right side of the article.
 
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:
* {{t|Book}} includes information on the publisher and ISBN of a book
* {{t|Character}} includes information regarding the character
* {{t|Place}} information on a place, region, or building.
* [[:Category:Infoboxes|Full list of Infoboxes]]
 
<pre style="white-space:pre-wrap; width:100px">
== Navigation boxes ==
{{name
Navboxes are footer templates that are placed at the bottom of a page to allow people to find related content.
|param1
|param2
|param3
}}
</pre>
 
=== Parameters ===
*{{t|Cosmere}} inserts a table of links relating to [[Adonalsium]] and the [[Cosmere]] at large
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.
*{{t|Books}} inserts a table of books and series' by [[Brandon Sanderson]]
*{{t|Elantris}} contains major articles about ''[[Elantris (book)|Elantris]]''
*{{t|Mistborn}} has stuff about the ''[[Mistborn series]]''
**{{t|Mistborn trilogy 1}}, {{t|Mistborn Adventures}} or {{t|Mistborn adventure game}} should be included on pages relaitng to those series
**{{t|Metallic arts}} inserts a table of the magics found on [[Scadrial]]
*{{t|Stormlight}} is the best place to start looking at stuff from ''[[The Stormlight Archive]]''
*{{t|Warbreaker}} has lots of links about ''[[Warbreaker]]'' and ''[[Nightblood]]''
**{{t|Awakening}} includes cool info about [[Awakening]]
* [[:Category: Navbars|Full list of Navbars]]
 
;Named Parameters
*{{t|holder}} indicates the holder of a title or other thing, and possible predecessors and successors.
: ''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
== Link macros ==
: ''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>.
*{{t|demonym}} returns the correct [[Wikipedia: demonym|demonym]] for a place
*{{t|toponym}} returns correct [[Wikipedia: toponym|toponyms]]
*{{t|world}} will convert book title's to the world on which the book is set
 
=== Citation templatesExample ===
Let's look at an example using the {{t|character}} template, which is used to create the infobox at the top of articles about characters. It creates a table with information that commonly pertains to characters. The different fields of the table are entered as parameters.
{{t|Ref}} generates a reference which may use one of the below templates to generate it's content.
**{{t|annotation}} links to a specific annotation
*{{t|tor}} links to a page on {{Tor|link=}}
*{{t|17s}} links to a topic on the {{17s|link=}}
*{{t|twg}} links to a topic on the {{twg|link=}}
*{{t|wp}} links to a page on [[wikipedia:Wikipedia]]
*{{t|bref}} links to a book or a specific chapter, page or section of a book
 
{| width=100% class=wikitable
== Editorial notations ==
|-
These templates are used to
| width=50%|When used in the [[Kelsier]] article, this...
*{{t|Cite}} requests that someone insert a citation about the fact preceding it.
|...produces:
*{{t|Clarify}} asks someone edit the page to clear up ambiguous statements
|-
*{{t|Disputed}} warn the reader that a fact may be incorrect or unverified
|<pre>
{{character
|image=Kelsier.jpg
|abilities=[[Allomancy|Mistborn]]
|spouse=[[Mare]]
|siblings=[[Marsh]]
|titles=Survivor
|born=c. 984 FE
|world=Scadrial
|ethnicity=Skaa
|residence=Luthadel
|books=[[Mistborn (series)]]
}}
</pre>
|
{{example
|name=Kelsier
|image=Kelsier.jpg
|abilities=[[Allomancy|Mistborn]]
|spouse=[[Mare]]
|siblings=[[Marsh]]
|titles=Survivor
|born=c. 984 FE
|world-raw=Scadrial
|ethnicity-raw=Skaa
|residence=Luthadel
|books=[[Mistborn (series)]]
}}
|}
 
== NavigationTypes of Templates aids==
Let's go over the common types of templates you may encounter and make use of.
These templates insert boxes or emphasised phrases that help users navigate the wiki correctly.
*{{t|For}} helps users distinguish between similarly titled articles.
 
=== Information Boxes ===
== [[:Category:Notices|Notices]] ==
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|location}}.
{{t|Notice}} templates insert boxes that alert users to information regarding the page its self.
*{{t|Attention}} requests that users edit it
*{{t|Copyright}} ask the user not to copy the content on the article
*{{t|Theory}} stipulates that the article or section should not be considered canon
*{{t|Spoilers}} warns users about new material they may not have read yet
*{{t|Delete}} and {{t|Move}} indicate possible administrative action
*{{t|Stub}} can be used to signify that an article is unfinished
*{{t|Complete}} should be used at the bottom of short articles when there is nothing more to add.
 
For more detailed help on infoboxes in general see [[:Help: Infoboxes]] and for a full list of infobox templates, see [[:Category: Infoboxes]].
== Other Templates ==
 
*{{t|B}} converts an acronym or malformed book title into the correctly formatted title.
=== Navigation Boxes ===
*{{t|Columns}} allows you to format a list (the first parameter) into <code>count</code> columns.
Called '''navboxes''' for short, these templates create the tables at the bottom of pages that link to other important articles that are related to the same book or series. Most series or standalone books have a navbox that refers to important characters, places, etc. Navboxes are placed at the end of the article, directly after the <code><nowiki><references /></nowiki></code> tag. Common examples include {{t|Cosmere}}, {{t|Stormlight}}, and {{t|Reckoners}}.
*{{t|Quote}} surrounds the first parameter as a block quote, with the second parameter as a source.
 
*{{t|Timeline}} aids in the creation of
For a full list of navbox templates, see [[:Category:Navbars]].
 
=== Notices ===
Notice templates alert users and editors of important information regarding the page itself. Some notable notice templates are listed below. For a full list of notice templates, see [[:Category:Notices]].
 
;{{t|attention}}
: Makes note at top of page that article needs attention and categorizes the article accordingly. Place directly after infobox.
 
;{{t|copyright}}
: Asks users not to copy the content on the article.
 
;{{t|theory}}
: Warns that the article or section contains speculation and should not be considered canon. Place directly after infobox or directly after section heading.
 
;{{t|spoilers}}
: Warns that the article contains information pertaining to recently published material that many users may not have read yet. Place directly after infobox.
 
;{{t|delete}}
: Requests that an administrator delete the page.
 
;{{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 macros]].
 
=== Editorial Notations ===
Editorial notations are used to highlight information which is unsupported, ambiguous, or questionable. For more, see [[:Help:References#Editorial_Notations|Help:References]].
 
=== Other Templates ===
Some other notable templates include the following:
 
;{{t|b}}
: This is a simple template that outputs a full book or series title given an abbreviated or shorthand reference. For example, "<code><nowiki>{{b|sa1}}</nowiki></code>" returns "{{b|sa1}}" (i.e. Stormlight Archive book 1).
 
;{{t|columns}}
: Use the {{t|columns}} template to create columns. Use <code><nowiki>{{columns|count=N|TEXT}}</nowiki></code>, where <code>N</code> is the desired number of columns and <code>TEXT</code> is the content to be split up into columns. Separate items in <code>TEXT</code> by using line breaks or lists. Note that <code>|count=N</code> may be omitted; the number of columns is 3 by default.
: {| width=100% class=wikitable
|-
| width=50%|This...
|...produces:
|-
|<pre style="white-space:pre-wrap; width:200px">
{{columns|count=2|
* Item 1
* Item 2
* Item 3
* Item 4
* Item 5
}}
</pre>
|{{columns|count=2|
* Item 1
* Item 2
* Item 3
* Item 4
* Item 5
}}
|}
 
;{{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|oodles of information|this page about the cosmere}}</nowiki></code> produces:
: {{for|cosmere|oodles of information|this page about the cosmere}}
 
== Template Pages ==
Templates are created just like articles and categories: you create a page for one in the Template namespace. You should find documentation for a template on this page. It will provide a description of what the template does, a list of required and acceptable parameters, and occasionally some examples.
 
== Editing Templates ==
Editing templates (or creating one from scratch) is definitely not a task for beginners. But we'll go over some of the basics.
 
=== Includeonly and Noinclude ===
;<code><nowiki><includeonly></nowiki></code> Tag
: Everything you want the template to do when used on other pages should be sandwiched between <code><nowiki><includeonly></nowiki></code> and <code><nowiki></includeonly></nowiki></code> tags.
 
;<code><nowiki><noinclude></nowiki></code> Tag
: The template's documentation, and anything else you want to show up on the template page itself, must be sandwiched between <code><nowiki><noinclude></nowiki></code> and <code><nowiki></noinclude></nowiki></code> tags.
 
=== Parameters ===
;Named Parameters
: ''Named'' parameters are referred to by their name in triple braces. For example, the named parameter "books" in the {{t|character}} template is referred to as <code>{{{books}}}</code>.
 
;Unnamed Parameters
: ''Unnamed'' parameters are referred to by the order they are entered. For example, the first unnamed parameter that is entered in the {{t|book ref}} template is referred to as <code>{{{1}}}</code>, while the second is referred to as <code>{{{2}}}</code>.
 
;Defaults
: Provide a default value for parameters by including a vertical bar (<code>|</code>) followed by the default value. To use a null default value, enter nothing after the vertical bar. For example, if you want the first unnamed parameter to have a default value of "Sanderson", use <code><nowiki>{{{1|Sanderson}}}</nowiki></code>.
 
=== 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:
 
;Uppercasing 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.
: ''Example:'' <code><nowiki>{{uc: heLLo}}</nowiki></code> produces <code>HELLO</code>.
 
;Lowercasing Text
: This function converts a string of text to all lowercase.
: ''Use:'' <code><nowiki>{{lc: TEXT}}</nowiki></code>, where <code>TEXT</code> is the text to be converted.
: ''Example:'' <code><nowiki>{{lc: heLLo}}</nowiki></code> produces <code>hello</code>.
 
;String Compare
: This function compares two strings of text and provides one of two results.
: ''Use:'' <code><nowiki>{{#ifeq: A|B|Result1|Result2}}</nowiki></code>, where <code>A</code> and <code>B</code> are the strings of text. If <code>A=B</code> then <code>Result1</code> is returned; otherwise, <code>Result2</code> is returned.
: ''Example:'' <code><nowiki>{{#ifeq: dog|dog|same|different}}</nowiki></code> produces <code>same</code> and <code><nowiki>{{#ifeq: dog|cat|same|different}}</nowiki></code> produces <code>different</code>.
 
;If-Then
: This function checks if a parameter exists and provides one of two results.
: ''Use:'' <code><nowiki>{{#if: A|Result1|Result2}}</nowiki></code>, where <code>A</code> is some parameter. If <code>A</code> exists (i.e. it isn't null) then <code>Result1</code> is returned; otherwise, <code>Result2</code> is returned.
: ''Example:'' If a second unnamed parameter is provided, <code><nowiki>{{#if: {{{2|}}}|hello|goodbye}}</nowiki></code> produces <code>hello</code>. If not, it produces <code>goodbye</code>.
 
;Case-Switch
: 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
: <code><nowiki>{{PAGENAME}}</nowiki></code> provides the name of the page/article. If used in this page it would yield <code>Templates</code>.
 
;Namespace
: <code><nowiki>{{NAMESPACE}}</nowiki></code> provides the name of the page's namespace. If used in this page it would yield <code>Help</code>.
 
=== Comments ===
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.
 
 
{{help
|title=New Editor's Guide
|prev=[[Help:Categories|Categories]]
|this=Templates
|next=[[Help:What now?|What now?]]
}}
Editors, Keepers
2,004

edits