Help:Templates

From Mario Fan Games Galaxy Wiki
Revision as of 03:33, 21 August 2009 by Baroque (talk | contribs) (Creation)
Wiki Basics
Wiki Editing
Wiki Formatting
Wiki Experience

Templates are a modern convienience that are used widely across this wiki. Every template page has the prefix "Template:" so that you can easily identify them.

Usage

To call a template, you use the following

{{templatename}}

Templates can be as simple as this, but they can also be quite complicated, allowing numerous sections to be defined. It may look something like this

{{template|name=Fred|age=542|numberofcars=Lots}

or it may have been organised so that it's easier on the eyes, like this

{{template
|name=Fred
|age=542
|numberofcars=Lots
}}

Each section may automatically fill in part of a table, sentence... you name it. Often the areas won't be labelled to keep it simple

{{template|Fred|542|Lots}

though obviously you may have difficulty understanding this.

Templates can contain pretty much anything a normal Wiki page can contain. The {{Help}} template on the top right of this page will automatically add this article to the Help Category for example.

You do not need the "Template:" prefix to call a template however - the two sets of curly brackets do that for you.

Creation

Template creation is a difficult and potentially dangerous undertaking and can cause gigantic problems across the Wiki if done improperly. First off, learn these:

  • MFGG Wiki does not have #if statements installed.
  • <noinclude> and </noinclude> are used to put guidance and clarification on a Template page that doesn't show when it's called by another page
  • <includeonly> and </includeonly> are used to make templates categorize pages without going into the category themselves.


Secondly, templates are similar to functions in other languages in that they may be passed parameters. For instance, if you call a Template with this:

{{Template
|this = hard
}}

You will have passed a parameter named this. In the template, you would call this parameter with triple brackets:

{{{this}}}

However, if there is no value for the parameter, it will display {{{this}}} instead of a value. To fix this, you use | to add a default:

{{{this|}}}

Whatever is after the | will be shown if {{{this}}} is not passed to the template. If there's nothing, then it will be blank, instead of showing {{{this}}}.

You can also nest parameters, which will let you put aliases:

{{{birthday|{{{dob|Unknown}}}}}}

In this case, passing either {{{birthday}}} or {{{dob}}} will have the same effect.

This can get very confusing. Do it sparingly.


You can also call a template with unnamed fields:

{{template|Bob|24|Golf}}

In which case, each parameter is called by number, starting with 1:

{|
|-
! {{{1|No name}}}
|-
! Age
| {{{2|Unknown age}}}
|-
! Interests
| {{{3|Unknown interests}}}
|}

It is generally a good idea to use numbered parameters for templates that only require one or two. For templates with many fields, especially if some of them are optional, it is better to ask for named parameters.

Types

There are several types of template as you could probably guess. MFGG currently has groups for

Some special ones have been covered in the rest of this guide.