Difference between revisions of "Help:Templates"

From Ballotpedia
Jump to: navigation, search
m
Line 1: Line 1:
{{BP help|Month=August 2013|Reason=Needs updates - Amanda Qualls}}{{help}}{{tnr}}A '''template''' is a page that can be inserted onto any number of other pages on Ballotpedia. A template has two parts:
+
{{help}}{{tnr}}A '''template''' is a page that can be inserted onto any number of other pages on Ballotpedia. A template has two parts:
  
 
* First, "template" refers to the page where a template has been built. This page '''always''' starts with the prefix: '''Template:''' followed by the name that has been chosen by that template's creator for the template.
 
* First, "template" refers to the page where a template has been built. This page '''always''' starts with the prefix: '''Template:''' followed by the name that has been chosen by that template's creator for the template.

Revision as of 22:51, 3 February 2014

Editing Help
1328101905 Help.png
Index
Editing guide
Cheatsheet
Policies
Copyright
Textual standards
Visual standards
Glossary of terms
Edit review process
A template is a page that can be inserted onto any number of other pages on Ballotpedia. A template has two parts:
  • First, "template" refers to the page where a template has been built. This page always starts with the prefix: Template: followed by the name that has been chosen by that template's creator for the template.
Example: Template:WikiProject Help
  • Second, "template" refers to the small bit of code you can use to insert a template into any other page on Ballotpedia. That small bit of code is always the words that appear after "Template:" on the page where the template exists.
Example: To insert the template for the Indiana onto any other page on Ballotpedia, you type {{Indiana}} on the page where you want it to appear. Here is an example.

Terminology

There are several terms you may see used in relations to templates. The most common are:

  • HNT (horizontal navigational template): This is usually found at the bottom of a page in a blue bar spanning the width of the page.
  • VNT (vertical navigational template): This is usually found along the right margin of the page. It is used to provide links to related pages on the wiki.
  • Infobox: A template with parameters that can be changed to provide specific information for the reader.

On HNTs, you will often see V, D and E links on the lefthand margin. These links stand for the following:

  • V (view): takes you to the actual template page, showing how it looks.
  • D (discussion): takes you to the discussion tab of the template page. Notes can be left on that page, and links to the relevant project or projects can be found on the discussion page.
  • E (edit): takes you to the edit box of the template page.

Template Basics

Reasons for templates

There are two main reasons that Ballotpedia contributors create and use templates:

  • Sometimes it is useful if the exact same information appears on a number of Ballotpedia pages. When this is the case, it is better to use a template that contains that information. Why? Because then when the information changes, it only needs to be changed on one page (the basic template page) and then it automatically is changed on all the pages where the template appears. For example, this template:


is a list of Indiana's current delegation to the United States Congress. The template is (or should be) inserted at the bottom of every article on Ballotpedia about one of those elected officials. When that group has a new individual elected to it, the list will need to be changed to include the newest addition and the former members removed. Because there's a template, the addition can simply be made on this page: Template:Indiana congress. As soon as someone adds the name of the new official to that page and saves it, each of the pages that include that template is automatically updated.

  • Templates can make it much, much easier for contributors and readers to navigate around easily on Ballotpedia in certain subsections of knowledge. Some template are referred to as "navigational boxes" for that reason--because they make it so easy to browse around in Ballotpedia in a clear, easy way without constantly having to use your "back" button.

Basic instructions

To include a template that already exists into an article you're working on, type the template's name in double curly brackets, sometimes also known as "braces". The braces or brackets key on your keyboard looks like: "{" or "}".

Simply type the name of the template, surrounded by two sets of braces, as in this example:

{{Alabama}}

Typing that gives you this:

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

Finding templates

Where do you find templates that might add value to the article you're working on? When a template is created, it should be added to the Category:Templates. Browsing through that category may familiarize you with some templates you might not otherwise have bumped into as you get to know Ballotpedia.

Advanced templates

Creating templates

It is very easy to create a new template. Anyone with regular editing privileges can create a template without any special permission. All you need to do is start a new article with the prefix, Template:.

For example, if you were to add some content to this page Template:Good new things and then click "save", you would have created a new template. The name of your new template is the words in the title of the article after the prefix; in this case, "Good new things".

Parameters

Though many templates only require their name to insert them into the page (example: {{Montana Supreme Court}}), 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 one parameter: the name of the new user who is being welcomed.

There are several points that need to be kept in mind with parameters:

  • "Pipe" characters (|) separate each parameter
  • Parameters can be optional or required
  • Parameters can be named or not named
    • Named parameters can be supplied in any order
    • Un-named parameters must be supplied in the defined order

Each template with parameters will have a list, which may look somewhat similar to this:

Template Parameters
(See using templates).
Name Purpose Required? Comment
1 The user name no (see note) Defaults to the page name


sig The signature of the editor posting the welcome ("~~~~" will do) no


The above list came from the {{Welcome}} template.

This list tells us the following:

  • Neither parameter is required
  • The first parameter (shown as "1") is not named, hence the number, which tells us 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. For example, in this case the welcome message would not show who it was from.

Named parameters have the parameter name followed by an equals sign (=) followed by whatever you want that to be.

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 (=).

Filling out parameters

In general, you can give a parameter any text that you like, however you should enter the specific information that is requested by the parameter.

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. However, a well-written template can allow you to simply omit the parameter altogether, as the {{welcome}} template does with the sig parameter.

Categorizing templates

Templates should be categorized, just like any other page or article. Templates should always have at least one category, but you may sometimes want to put your template into two or more different categories.

The categories your template may be added to are:

  • The category for the type of article it is a template for.

The "no include" option

Templates have a special feature when it comes to categories; namely, you can put a category tag on a template as a "no include" or not.

  • If you don't put your template in the "no include" category, then whatever category you do put your template in will automatically cause any article you attach your template to to also appear in that category.
  • Depending on the type of template you've created, this can be a good thing or a bad thing. That's why the "no include" option exists.
  • Consider Template:Kansas Supreme Court. This template has two categories:
  • Kansas Supreme Court
  • State supreme court templates
Both categories are "no include" categories. That means that whenever you add the template {{Kansas Supreme Court}} to an article, the article won't automatically be added to those categories.

Requesting a templates

Would you like a template that doesn't already exist to be built by someone who is more familiar with building templates? If so, you can get the attention of someone who is skilled at creating templates by leaving that person a note on his or her user talk page. After you leave a message, the next time that person logs on, he or she will automatically be alerted that they have a new message.

External links