Help:Using templates

From Conservapedia

Jump to: navigation, search

Using templates can be easy or hard, depending on the template. But normally they are easy.

{{mainpageright}}

Contents


Basic instructions

A template is simply a page (usually a very brief one) that is inserted into another page.

For example, the two separate boxes on the Main Page ("Mainpageleft" and "Mainpageright") are each actually separate pages that are "included" on the Main Page. In fact, they can be included on any page: The "Mainpageright" page has been included to the right just to demonstrate that point[1]:

Templates are included on a page by typing the page name in double curly brackets. So to include this page on another page, you could type {{help:Using templates}}. If, however, the template is in "template" namespace (i.e. the page name starts with "template:"), then you don't need to include that bit. So to include the "Mainpageright" page, you would just type {{Mainpageright}}.

For simple templates, that's all there is to it.

Parameters

However, many templates allow you to add to the information in the template, or to change it's appearance, by supplying parameters.

For example, the Welcome template that someone might have put on your user talk page has two parameters. One is the name of the user, and the other is the name of the person placing the welcome message. See the example below welcoming The Joker, placed by Batman: <div style="width:65%"><small><small>{{welcome|Joker|sig=from Batman}}</small></small></div>

(This was included on this page by typing {{welcome|Joker|sig=from Batman}}.[1])

"Pipe" characters (|) separate each parameter.

Parameters can be optional or required, and they can be named or not named. In the example above, the first parameter ("Joker") was not named, but the second ("from Batman") was named sig. Two points need to be kept in mind with parameters:

  • Named parameters can be supplied in any order.
  • Un-named parameters must be supplied in the correct order.

See below for how parameters are provided to templates.

Each template has (or will have) a list of parameters, looking something like this (this one is from the {{welcome}} template):

Template Parameters
(See using templates).
NamePurposeRequired?Comment
1The user nameno (see note)Defaults to the page name
sigThe signature of the editor posting the welcome ("~~~~" will do)no

This tells us the following:

  • Neither parameter is required.
  • The first parameter (shown as "1") is not named (hence the number, the order in which it must be supplied).
  • The second parameter is named ("sig").
  • If the first parameter is not supplied, then the page name is used instead.

You can assume that if no default is shown for a parameter that is not required, the result will be blank (i.e. in this case, the welcome message would not show who it was from).

To supply a value to a named parameter, put the parameter name followed by an equals sign (=) followed by whatever you want that to be. In the example above, this is sig=~~~~.

Parameters shown with numbers are the un-named parameters. You can treat them as named parameters, by typing 1=your text, but this is not necessary, except in the case that you want your text to include an equals sign (=). Normally you just supply the value, such as YourUserName.

Each parameter is separated from each other, and from the template name, by a 'pipe' character: |.

So supplying both parameters in the {{welcome}} template would look like this: {{welcome|YourUserName|sig=~~~~}}.

What do you pass to parameters?

Obviously, you give a parameter the text that it expects, such as "from Batman" in the example above. But in most cases, you can give a parameter any text that you like. You could, for example, put "But break any laws and I'll bring the full weight of the law down on you, (signed) Batman"!

In some cases, however, specific text must be supplied. The {{Bible ref}} template, for example, expects a book of the Bible for the "book" parameter, and giving it something that is not a book of the Bible will break the link to BibleGateway that the template creates.

In many cases you can supply a blank value to the parameter. You can set a parameter to be blank by typing nothing after the pipe character for an unnamed parameter, or nothing after the equals sign for a named parameter. For example, if you wanted the welcome template to not show "Joker" or "from Batman", you could type {{welcome||sig=}}.

However, a well-written template will allow you to simply omit the parameter altogether, as the {{welcome}} template does with the sig parameter.

Notes

  1. 1.0 1.1 The "Mainpageright" and "welcome" templates on this page have been reduced in size to fit better.
Personal tools