Help:Template: Difference between revisions
More actions
Page for beginner template use |
|||
| (9 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{For see|a list of templates|[[:Category:Template]].<br><br> | |||
:This article is heavily focused on providing a brief overview of templates used in the Destiny Wiki. For more advanced information, see [[:Wikipedia:Help:Template]]}} | |||
{{Help sidebar}} | {{Help sidebar}} | ||
The wiki has a variety of '''templates''' that help aid user readability, navigability, functionality and aesthetic. This page will serve to attempt to outline all of these categories, as well as templates within them. Any wiki user can create or edit a template, but keep in mind that editing a template will affect how the template appears on ''all'' pages that it has been transcluded to. | The wiki has a variety of '''templates''' that help aid user readability, navigability, functionality and aesthetic. This page will serve to attempt to outline all of these categories, as well as templates within them. | ||
Any wiki user can create or edit a template, but keep in mind that editing a template will affect how the template appears on '''all''' pages that it has been transcluded to. | |||
== What is a Template? == | == What is a Template? == | ||
A template is reference material that has been transcluded ''(see [[Wikipedia:Help:Transclusion]] for more information on how transclusion works)'' | A template is reference material that has been transcluded onto another page for easy repetition of information or functionality. | ||
:{{small|''(see [[Wikipedia:Help:Transclusion]] for more information on how transclusion works)''}} | |||
For example, the {{tl|Meme sidebar}} allows for easy user navigability to other [[Memes]] or [[:Category:Memes]] that might be useful to the end user in order to reduce their interaction with otherwise "messy" pages (primarily category pages which some users might find difficult or confusing to utilize.) | |||
:{{small|''(see [[Wikipedia:Help:Categories]] for more information on categories)''}} | |||
== How do I use Templates? == | == How do I use Templates? == | ||
Templates are <u>always</u> identified by a set of an opening and closing pair of double curly brackets (i.e. <code>{{</code> and <code>}}</code>) to indicate the start and stop of the template. Both pairs of brackets are required for the template to function. A full example of how a template could be written is as follows: | Templates are <u>always</u> identified by a set of an opening and closing pair of double curly brackets (i.e. <code>{{</code> and <code>}}</code>) to indicate the start and stop of the template. Both pairs of brackets are required for the template to function. A full example of how a template could be written is as follows: | ||
<code>{{tl|WIP}}</code>. | <code>{{tl|WIP}}</code>. {{tl|WIP}} is used to denote that a page is under heavy writing, restructuring, or is otherwise incomplete and may be difficult to parse if read. When properly typed into a page, it will display as follows: | ||
{{WIP}} | {{WIP}} | ||
Here you can see that the template | :{{small|''Here you can see that the template uses color, an icon, as well as boldened text to draw the attention of the reader to it before proceeding with the article. It's important to use templates strategically as they may not always be necessary.''}} | ||
=== Parameters === | === Parameters === | ||
==== Un-named Parameters ==== | ==== Un-named Parameters ==== | ||
There is another component to most templates, which are parameters. Parameters allow you to define certain aspects of a given template provided they have been written into the template; for example, | There is another component to most templates, which are parameters. Parameters allow you to define certain aspects of a given template provided they have been written into the template; for example, {{tl|Color}} is used to easily change the color of text (such as on the [[Flair]]s article) in order to {{color|red|||change the color}} of different flair names, and has four '''un-named parameters'''. Un-named parameters have no assigned word-value and thus must be entered in order as written in the template.* The color template for example has the four following parameters that are common in many templates: | ||
:''{{small|(You '''can''' enter them out of order as long as you specify the 1. number and 2. add an "{{=}}" sign to specify you are defining the value for that number, i.e. <code><nowiki>{{notarealtemplate|2=weow|1=OOOO}}</nowiki></code>, however if you do this, you should define '''''all''''' parameters this way. This also applies to named parameters.)}}'' | |||
===== Parameter 1 ===== | ===== Parameter 1 ===== | ||
'''The color of the text.''' For any template with a color parameter, you can use HTML pre-specified colors, HEX codes (i.e. #a0a, #00aaff, etc.), HSL/HSLA (i.e. hsla(50, 45%, 20%, .2)) Be sure to consider accessibility of selected colors if you do use them, as color-blind users may have difficulty reading certain color combinations, and some users may use non-standard wiki themes (such as the citizen theme), custom wiki themes, or browser plugins that may invert or change the color on the page. | '''The color of the text.''' For any template with a color parameter, you can use HTML pre-specified colors, HEX codes (i.e. #a0a, #00aaff, etc.), HSL/HSLA (i.e. hsla(50, 45%, 20%, .2)) Be sure to consider accessibility of selected colors if you do use them, as color-blind users may have difficulty reading certain color combinations, and some users may use non-standard wiki themes (such as the citizen theme), custom wiki themes, or browser plugins that may invert or change the color on the page. | ||
===== Parameter 2 ===== | ===== Parameter 2 ===== | ||
'''The color of the highlight.''' Not as common. Considerations above still apply. | '''The color of the highlight.''' Not as common. Considerations above still apply. | ||
===== Parameter 3 ===== | ===== Parameter 3 ===== | ||
'''The size of the highlight.''' Many templates will let you control the size of an element within it. For example, | '''The size of the highlight.''' Many templates will let you control the size of an element within it. For example, {{tl|Color}} allows you to {{color|black|#ffcc33||highlight text}}, and optionally {{color|black|#ffcc33|3px|make the highlight larger}}, or even {{color|black|#ffcc33|6px|obnoxiously large.}} Be sure to consider the resizing of any elements for cleanness as well as consider display on mobile devices. For size parameters, you can use percentages (i.e. "50%"), pixels, (i.e. "50px") or CSS units like "em", "rem", etc. | ||
===== Parameter 4 ===== | ===== Parameter 4 ===== | ||
'''The text.''' This is one of the most common parameters in any given template, as most templates on the wiki are used to preserve a certain "style" (for example, | '''The text.''' This is one of the most common parameters in any given template, as most templates on the wiki are used to preserve a certain "style" (for example, {{tl|Mbox}} is a base template for {{tl|WIP}}, {{tl|Stub}}, and {{tl|Expand Section}}). | ||
===== Using a template with un-named parameters ===== | ===== Using a template with un-named parameters ===== | ||
Templates with un-named parameters are about as common as templates with named parameters, so it's important to know how they function. Typically a template that is meant to be in-line (as in, in-line with the text and not it's own separate element) will have un-named parameters to reduce bloat so that an editor of a page does not have as difficult of a time viewing it as they would with named parameters (which use up more space.) As discussed above, un-named parameters are entered in order of how they are specified in the template. For this example, we will be looking at | Templates with un-named parameters are about as common as templates with named parameters, so it's important to know how they function. Typically, a template that is meant to be in-line (as in, in-line with the text and not it's own separate element) will have un-named parameters to reduce bloat so that an editor of a page does not have as difficult of a time viewing it as they would with named parameters (which use up more space.) As discussed above, un-named parameters are entered in order of how they are specified in the template. For this example, we will be looking at {{tl|Wiki}} which provides an easy way to link to pages on Wikipedia (as well as visually distinguish it from other external links). The Template is laid out as follows: | ||
:<code><nowiki>{{wiki|1|2|3}}</nowiki></code> | |||
If we assign a label to each numbered parameter, it will appear as the following: | |||
:<code><nowiki>{{wiki|page name|display text|punctuation}}</nowiki></code> | |||
This allows us to input some basic information knowing where everything should go, such as: | |||
:<code><nowiki>{{wiki|Destiny (streamer)|Steven Bonell|!}}</nowiki></code> | |||
Inputting this would produce something in-line, like a link to {{wiki|Destiny (Streamer)|Steven Bonell|!}} | |||
Some templates also don't require every parameter to be filled, exemplified by inputting something like <code><nowiki>{{wiki|Hasan Piker||.}}</nowiki></code>, netting a link to {{wiki|Hasan Piker||.}} | |||
:''{{small|(Note the the "{{!}}" character (referred to as a pipe) for the second and third parameters are still there despite the second parameter being left blank, this is done because the {{tl|wiki}} template automatically uses the first parameter (the page name) as the display name if no other alternate display is selected, this may not always be the case in other templates.)}}'' | |||
==== Named Parameters ==== | |||
Named parameters are the other type of parameters. They are similar to un-named parameters, but are required to be specified in the template text in order to be defined. The above section on un-named parameters will mostly apply to named parameters as well, with the added step of defining which parameter you want to identify (in an order of your choosing). For this section, we will explore {{tl|Blockquote}} as an example of a template with named parameters. This template has two parameters, the name of the individual ("name") and the text quoted ("quote"), and can be written as follows: <code><nowiki>{{blockquote|name=Destiny|quote=Whiplash is a 10/10 movie.}}</nowiki></code>, or in a blocked format as follows: | |||
<nowiki>{{blockquote | |||
|name = Destiny | |||
|quote = Whiplash is a 10/10 movie | |||
}}</nowiki> | |||
This will provide a large, block style quote with the inputted information, displaying as: | |||
{{blockquote|name=Destiny|quote=Whiplash is a 10/10 movie.}} | |||
{{tl|Blockquote}} additionally has optional parameters, so, if you did not want to include a name on the quote, you could leave out the parameter "name" (you could also leave out "quote" but it wouldn't make much sense for this particular scenario), for example <code><nowiki>{{blockquote|quote=Whiplash is a 10/10 movie.}}</nowiki></code> will net: | |||
{{blockquote|quote=Whiplash is a 10/10 movie.}} | |||
=== Templates without Parameters === | |||
Some templates do not require parameters, and exist solely to transclude simple information into a location. Two examples of this include {{tl|Olb}}, which allows for an easy entry of a color (the color used by Destiny's logo) into several different locations, the use of this template is three-fold: | |||
# Allows the color to stay consistent. | |||
# Allows the color to be easily changeable by editing the template. | |||
# Allows contributors to more easily insert the color in areas where it might be desired. | |||
Another example is {{tl|Rpointer}}, used by {{tl|Sidebar}} and derivative templates (such as {{tl|Help sidebar}} and {{tl|Meme sidebar}}) for similar reasons above. | |||
=== Documentation === | === Documentation === | ||
The template page should have documentation (created using the | The template page should have documentation (created using the {{tl|Documentation}}) supporting it to provide what each parameter is, what it controls, as well as when and how to use the template, as well as examples of the template. Some templates may not have documentation due to time constraints or low importance, but support with templates can always be provided by reaching out to the author of the template, [https://discord.com/channels/265256381437706240/1152047669708075080 #dgg-wiki] channel in the Destiny discord, or [[User:Devonnn]]. | ||
[[Category:Help]] | |||
=== Creating Templates === | |||
Creating templates can be confusing at first, especially for any users who might be unfamiliar with coding/basic logic (in written form) and/or HTML. The author of this article ([[User:Devonnn]]) has <u>never</u> worked with wiki templates, any coding languages, or HTML before starting contributing to the wiki. There will be an adjustment period if you want to learn how to create templates. There are a few things highly recommended to learn how to create templates: | |||
# '''Look for official WikiMedia/Wikipedia resources.''' Wiki resources are prevalent and comprehensive, some helpful articles might include: | |||
## [[Wikipedia:Help:Template#Writing templates]] | |||
## [[Mediawikiwiki:Help:Templates]] | |||
# '''Look for templates that have already been made.*''' There is no point re-treading old ground, Wikipedia and Wikimedia templates are all licensed under the Creative Commons BY-SA License and can be used as long as proper attribution is given (in this case, Wikipedia states that for text from Wikipedia, '''"you may satisfy attribution either by providing a complete list of authors of the original content (the complete list can be generated by copying the history of the remote page) or by providing a direct link to the original material."**''' You can use {{tl|Interwiki copy}} to satisfy these requirements.<br><br>Be advised that much of Wikipedia uses Lua for some templates (typically those made past 2014-2016,) so if any modules that Wikipedia has are not on this wiki, they may not work correctly, you can also look for older versions of the template. | |||
#: {{small|''*Please ensure you follow all applicable copyright laws.''}} | |||
#: {{small|''**(per [[:Wikipedia:Wikipedia:Copying within Wikipedia#Copying from other Wikimedia projects|Wikipedia:Copying within Wikipedia § Copying from other Wikimedia projects]]).''}} | |||
# '''Look at other templates for ideas, inspiration, or process.''' You can view templates on the Destiny below, or look on other wiki projects that use wikitext for inspiration. | |||
<!--- | |||
== Master list of all Templates == | |||
The following list is broken down by category of templates, and as such may contain the same template multiple times as it may meet criteria for multiple listings. | |||
::Coming soon lol | |||
---> | |||
Latest revision as of 21:06, 14 November 2024
For a list of templates, see Category:Template.
|
| This article is part of a series on |
| Wiki Contribution |
General
|
Tools
|
Miscellaneous
|
The wiki has a variety of templates that help aid user readability, navigability, functionality and aesthetic. This page will serve to attempt to outline all of these categories, as well as templates within them.
Any wiki user can create or edit a template, but keep in mind that editing a template will affect how the template appears on all pages that it has been transcluded to.
What is a Template?
A template is reference material that has been transcluded onto another page for easy repetition of information or functionality.
- (see Wikipedia:Help:Transclusion for more information on how transclusion works)
For example, the {{Meme sidebar}} allows for easy user navigability to other Memes or Category:Memes that might be useful to the end user in order to reduce their interaction with otherwise "messy" pages (primarily category pages which some users might find difficult or confusing to utilize.)
- (see Wikipedia:Help:Categories for more information on categories)
How do I use Templates?
Templates are always identified by a set of an opening and closing pair of double curly brackets (i.e. {{ and }}) to indicate the start and stop of the template. Both pairs of brackets are required for the template to function. A full example of how a template could be written is as follows:
{{WIP}}. {{WIP}} is used to denote that a page is under heavy writing, restructuring, or is otherwise incomplete and may be difficult to parse if read. When properly typed into a page, it will display as follows:
|
- Here you can see that the template uses color, an icon, as well as boldened text to draw the attention of the reader to it before proceeding with the article. It's important to use templates strategically as they may not always be necessary.
Parameters
Un-named Parameters
There is another component to most templates, which are parameters. Parameters allow you to define certain aspects of a given template provided they have been written into the template; for example, {{Color}} is used to easily change the color of text (such as on the Flairs article) in order to change the color of different flair names, and has four un-named parameters. Un-named parameters have no assigned word-value and thus must be entered in order as written in the template.* The color template for example has the four following parameters that are common in many templates:
- (You can enter them out of order as long as you specify the 1. number and 2. add an "=" sign to specify you are defining the value for that number, i.e.
{{notarealtemplate|2=weow|1=OOOO}}, however if you do this, you should define all parameters this way. This also applies to named parameters.)
Parameter 1
The color of the text. For any template with a color parameter, you can use HTML pre-specified colors, HEX codes (i.e. #a0a, #00aaff, etc.), HSL/HSLA (i.e. hsla(50, 45%, 20%, .2)) Be sure to consider accessibility of selected colors if you do use them, as color-blind users may have difficulty reading certain color combinations, and some users may use non-standard wiki themes (such as the citizen theme), custom wiki themes, or browser plugins that may invert or change the color on the page.
Parameter 2
The color of the highlight. Not as common. Considerations above still apply.
Parameter 3
The size of the highlight. Many templates will let you control the size of an element within it. For example, {{Color}} allows you to highlight text, and optionally make the highlight larger, or even obnoxiously large. Be sure to consider the resizing of any elements for cleanness as well as consider display on mobile devices. For size parameters, you can use percentages (i.e. "50%"), pixels, (i.e. "50px") or CSS units like "em", "rem", etc.
Parameter 4
The text. This is one of the most common parameters in any given template, as most templates on the wiki are used to preserve a certain "style" (for example, {{Mbox}} is a base template for {{WIP}}, {{Stub}}, and {{Expand Section}}).
Using a template with un-named parameters
Templates with un-named parameters are about as common as templates with named parameters, so it's important to know how they function. Typically, a template that is meant to be in-line (as in, in-line with the text and not it's own separate element) will have un-named parameters to reduce bloat so that an editor of a page does not have as difficult of a time viewing it as they would with named parameters (which use up more space.) As discussed above, un-named parameters are entered in order of how they are specified in the template. For this example, we will be looking at {{Wiki}} which provides an easy way to link to pages on Wikipedia (as well as visually distinguish it from other external links). The Template is laid out as follows:
{{wiki|1|2|3}}
If we assign a label to each numbered parameter, it will appear as the following:
{{wiki|page name|display text|punctuation}}
This allows us to input some basic information knowing where everything should go, such as:
{{wiki|Destiny (streamer)|Steven Bonell|!}}
Inputting this would produce something in-line, like a link to Steven Bonell!
Some templates also don't require every parameter to be filled, exemplified by inputting something like {{wiki|Hasan Piker||.}}, netting a link to Hasan Piker.
- (Note the the "|" character (referred to as a pipe) for the second and third parameters are still there despite the second parameter being left blank, this is done because the {{wiki}} template automatically uses the first parameter (the page name) as the display name if no other alternate display is selected, this may not always be the case in other templates.)
Named Parameters
Named parameters are the other type of parameters. They are similar to un-named parameters, but are required to be specified in the template text in order to be defined. The above section on un-named parameters will mostly apply to named parameters as well, with the added step of defining which parameter you want to identify (in an order of your choosing). For this section, we will explore {{Blockquote}} as an example of a template with named parameters. This template has two parameters, the name of the individual ("name") and the text quoted ("quote"), and can be written as follows: {{blockquote|name=Destiny|quote=Whiplash is a 10/10 movie.}}, or in a blocked format as follows:
{{blockquote
|name = Destiny
|quote = Whiplash is a 10/10 movie
}}
This will provide a large, block style quote with the inputted information, displaying as:
| Whiplash is a 10/10 movie. |
| — Destiny |
{{Blockquote}} additionally has optional parameters, so, if you did not want to include a name on the quote, you could leave out the parameter "name" (you could also leave out "quote" but it wouldn't make much sense for this particular scenario), for example {{blockquote|quote=Whiplash is a 10/10 movie.}} will net:
| Whiplash is a 10/10 movie. |
Templates without Parameters
Some templates do not require parameters, and exist solely to transclude simple information into a location. Two examples of this include {{Olb}}, which allows for an easy entry of a color (the color used by Destiny's logo) into several different locations, the use of this template is three-fold:
- Allows the color to stay consistent.
- Allows the color to be easily changeable by editing the template.
- Allows contributors to more easily insert the color in areas where it might be desired.
Another example is {{Rpointer}}, used by {{Sidebar}} and derivative templates (such as {{Help sidebar}} and {{Meme sidebar}}) for similar reasons above.
Documentation
The template page should have documentation (created using the {{Documentation}}) supporting it to provide what each parameter is, what it controls, as well as when and how to use the template, as well as examples of the template. Some templates may not have documentation due to time constraints or low importance, but support with templates can always be provided by reaching out to the author of the template, #dgg-wiki channel in the Destiny discord, or User:Devonnn.
Creating Templates
Creating templates can be confusing at first, especially for any users who might be unfamiliar with coding/basic logic (in written form) and/or HTML. The author of this article (User:Devonnn) has never worked with wiki templates, any coding languages, or HTML before starting contributing to the wiki. There will be an adjustment period if you want to learn how to create templates. There are a few things highly recommended to learn how to create templates:
- Look for official WikiMedia/Wikipedia resources. Wiki resources are prevalent and comprehensive, some helpful articles might include:
- Look for templates that have already been made.* There is no point re-treading old ground, Wikipedia and Wikimedia templates are all licensed under the Creative Commons BY-SA License and can be used as long as proper attribution is given (in this case, Wikipedia states that for text from Wikipedia, "you may satisfy attribution either by providing a complete list of authors of the original content (the complete list can be generated by copying the history of the remote page) or by providing a direct link to the original material."** You can use {{Interwiki copy}} to satisfy these requirements.
Be advised that much of Wikipedia uses Lua for some templates (typically those made past 2014-2016,) so if any modules that Wikipedia has are not on this wiki, they may not work correctly, you can also look for older versions of the template.- *Please ensure you follow all applicable copyright laws.
- **(per Wikipedia:Copying within Wikipedia § Copying from other Wikimedia projects).
- Look at other templates for ideas, inspiration, or process. You can view templates on the Destiny below, or look on other wiki projects that use wikitext for inspiration.