Help:Editing/Templates

From SRB2 Wiki
Jump to navigation Jump to search
  Help [view]
Wiki editing help Main pageImagesTablesTemplatesList of templates
Manual of Style Main pageModifications
SRB2 troubleshooting Main page

If you have standard texts that you want to include on several pages, the MediaWiki template feature comes into play. Templates are an effective way to include texts that may be used on many pages. For one, it makes including the same content across several pages easier to use. For another, if a change were be made to the text, the change can be made solely on the template page, and that one modification will be reflected on all the pages that use the template.

Creating a template

Template names are prefixed with Template:. They may be created like any other page on a Wiki. However, there are additional steps necessary to completely make a new template:

  1. Make the template, specifically the content you want shown on other pages.
  2. Include instructions on how to use the template. Template:Spoilers is a good example on how this is done.
  3. Put the template in Category:Templates, as well as the appropriate sub-category(ies). Sub-categories are listed here. In the end, the template should have at least two category listings.
  4. Save the template.
  5. List the template in the Help:Editing/List of templates page, under said sub-category. Provide a link and a description on when to use it.
  6. If you used a new icon, list it on this page, under Icons.

Using a template

The real shine of templates come to light when involving their ability to be included in other pages. This can be done in three ways:

{{Name}} includes the current content of the page "[[Template:Name]]".
{{subst:Name}} directly inserts the content of the page "[[Template:Name]]" when you save your text.
{{msgnw:Name}} includes the template in raw wiki syntax, like <nowiki> does.

The first method is the usual, and recommended, method to include a template. The second, in some circumstances, is more appropriate, but it's sometimes hard to discern when to use this method or the first one. Using the second method means the text would be directly inserted to the page, so any changes to the Template page will not be reflected on the other page. The third method is reserved mainly for technical and demonstration purposes. It's practically equivalent to wrapping <nowiki> around the template.

Parameters

Template with Numbered Parameters
 
'''A little thank you...'''<br>
<small>for {{{1}}}.<br>
hugs, {{{2}}}</small>

You Type You Get
{{Thankyou|all|John Doe}}
Sonic Robo Blast 2
Sonic Robo Blast 2
A little thank you...
for all.
hugs, John Doe
With Named Parameters
 
'''A little thank you...'''<br>
<small>for {{{reason}}}.<br>
hugs, {{{signature}}}</small>

You Type You Get

{{Thankyou|
| reason = all
| signature = John Doe}}

Sonic Robo Blast 2
Sonic Robo Blast 2
A little thank you...
for all.
hugs, John Doe

You can define parameters in templates either numbered as {{{1}}} or named {{{param}}}.

Example: you want a little thank you note you can put other users on their talk page with a reason and your signature. In the Template:Thankyou you enter your text.

When using the template on a page, you fill in the parameter values, separated by a pipe char (|): {{Thankyou|all|Joe}}. For named parameters use "name=value" pairs separated by a pipe char: {{Thankyou|reason=all|signature=Joe}}. The advantage of using named parameters in your template is that they are flexible in order; named parameters can be defined in any order. It also makes the template easier to understand if you have many parameters. If you want to change the order of numbered parameters, you have to mention them explicitly: {{Thankyou|2=Joe|1=all}}.

Better, still, is that using named parameters allows the template tag to be formatted in a more comprehensive format, like such:

{{Thankyou|
| reason = all
| signature = Joe
}}

Formatting template tags in this manner allows the tag to be more human-readable.

Controlling template inclusion

You can control template inclusion by the use of <noinclude> and <includeonly> tags.

Anything between <noinclude> and </noinclude> will be processed and displayed only when the page is being viewed directly, not included.

Possible applications are:

  • Categorising templates
  • Interlanguage links to similar templates in other languages
  • Explanatory text about how to use the template

The converse is <includeonly>. Text between <includeonly> and </includeonly> will be processed and displayed only when the page is being included. The obvious application is to add all pages containing a given template to a category.

Note that the usual update problems apply – if you change the categories inside a template, the categories of the referring pages won't be updated until those pages are edited.

Template description

For templates to be effective users need to find them and be able to use them. Wikis are not user friendly when it comes to finding, using and working with templates. A simple technique is to have a usage on the template page. For example:

==Usage==
Allows to establish a link to a subject:
{{NameOfTemplate|Term1+Term2+Term3}}

A usage text on the template page can tell the user what the template is used for and how to use the template, including variables to use. When writing usage text, it's best to enclose it in <noinclude> tags, so the usage text doesn't get included alongside the template text in a page.

Variables

MediaWiki has some pre-defined variables which can be used in texts. They are rendered differently depending on the time, the site and the page. Their syntax is similar to templates (even though they're not real pages in the Template namespace, but instead they are actual variables.) If you want a page to show always the current time, you use {{CURRENTTIME}}. To distinguish variables from templates, most variables are capitalized.

Description You Type You Get
Date & Wiki Variables
Current Month {{CURRENTMONTH}} 03
Current Month {{CURRENTMONTHNAME}} March
Genitive Form
of Current Month Name
{{CURRENTMONTHNAMEGEN}} March
Abbreviated Month Name {{CURRENTMONTHABBREV}} Mar
Day of the Month {{CURRENTDAY}} 23
Day of the Week {{CURRENTDOW}} 6
Day of the Week {{CURRENTDAYNAME}} Saturday
Week {{CURRENTWEEK}} 12
Year {{CURRENTYEAR}} 2024
Current Time {{CURRENTTIME}} 00:43
Numbers of Articles in this Wiki {{NUMBEROFARTICLES}} 1,449
Numbers of Uploaded Files {{NUMBEROFFILES}} 4,872
Namespaces
{{ns:-2}} or {{ns:Media}} Media
{{ns:-1}} or {{ns:Special}} Special
{{ns:1}} or {{ns:Talk}} Talk
{{ns:2}} or {{ns:User}} User
{{ns:3}} or {{ns:User_talk}} User talk
{{ns:4}} or {{ns:Project}} SRB2 Wiki
{{ns:5}} or {{ns:Project_talk}} SRB2 Wiki talk
{{ns:6}} or {{ns:Image}} File
{{ns:7}} or {{ns:Image_talk}} File talk
{{ns:8}} or {{ns:MediaWiki}} MediaWiki
{{ns:9}} or {{ns:MediaWiki_talk}} MediaWiki talk
{{ns:10}} or {{ns:Template}} Template
{{ns:11}} or {{ns:Template_talk}} Template talk
{{ns:12}} or {{ns:Help}} Help
{{ns:13}} or {{ns:Help_talk}} Help talk
{{ns:14}} or {{ns:Category}} Category
{{ns:15}} or {{ns:Category_talk}} Category talk
Server-specific
Site Name {{SITENAME}} SRB2 Wiki
Server Name {{SERVERNAME}} wiki.srb2.org
Server {{SERVER}} //wiki.srb2.org
Script Path {{SCRIPTPATH}} /w
Local Part of URL {{localurl:pagename}} /wiki/Pagename
Local part of URL,
with Queries
{{localurl:pagename|query string}} /w/index.php?title=Pagename&query string
Page-related
Page Name {{PAGENAME}} Editing/Templates
Page Name
(URL Encoded)
{{PAGENAMEE}} Editing/Templates
Namespace {{NAMESPACE}} Help
Revision ID {{REVISIONID}} 97595

Visual style

Templates should follow a standardized look, which are described as follows:

Informational messages

  • Informational messages affecting only the article content itself should be in plain, indented italics, unless they're really important. For example, spoilers and warnings relevant to the article get a box template.
  • Informational message templates displayed in box format can use any colors. It's best to look at existing templates to get an idea of which colors to use.

Wiki operations

  • Messages directly affecting Wiki operations, such as editing pages, style policy, deletion, etc., should be in boxes, following a certain color code:
    • Non-urgent notice: Gray
      • border: 1px #AAAAAA solid;
      • background-color: #F2F2F2;
Template text goes here.
  • Medium importance: Orange (most maintenance actions fall under these)
    • border: 1px #FFA500 solid;
    • background-color: #FBF9E7;
Template text goes here.
  • High importance: Red
    • border: 1px #FF0000 solid;
    • background-color: #FCF1E6;
Template text goes here.

Icons

While informational templates (indented italicized) don't usually have icons, box templates make almost universal use of them. Below are images suitable for box templates:

  • [[Image:NoteIcon.png]]
  • [[Image:Information.png|50px]]
  • [[Image:Warning_icon.png]]
  • [[Image:test.png|50px]]
  • [[image:Hand.png|50px]]
  Help [view]
Wiki editing help Main pageImagesTablesTemplatesList of templates
Manual of Style Main pageModifications
SRB2 troubleshooting Main page