Help:Contents/Using Templates (Pre-made text)

From MarketsWiki
< Help:Contents
Revision as of 13:42, 27 July 2017 by SarahRudolph (talk | contribs) (→‎Why Templates?)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Templates are special wiki pages that are designed to be copied into articles.

Why Templates?[edit]

Three words: Standardization. Convenience. Consistency.

Let's say you're creating a new article for a company, and you realize when you're done that there is much more that could be added. You'd like to flag that article as needing more information.

You could create a display box at the top of the page asking for help. However, the next article you write might also need help, and you'd have to write the code to make that display box all over again. Meanwhile, three other authors are facing the same situation as you, and are creating their own solutions for the same need.

Heaven forbid if after your tenth page, you realize you've misspelled "infromaton" on the first one and copied and pasted it nine more times. Now you have to dig through all of your changes and new pages to look for spelling errors.

What if there were a way to create text, a display box or other information ONCE, and then have everybody use it on their pages? Every page needing more information would have the exact same request at the top of their pages. If you mistakenly asked for more "infromaton," correcting the spelling in one place would fix it everywhere. And authors could concentrate on writing articles rather than building wiki structures.

Well, that's what a template is, and that's why we use them.

Template Structure and Usage[edit]

Templates are special pages that begin with the prefix "Template:". For example the "HelpAddContent" template's full name in the wiki is, "Template:HelpAddContent". Other than that, the overall structure of a template page is the same as for any other article.

Unless you're creating a new template, though, you don't need to worry about the "Template:" prefix. It's not used anywhere in articles.

To use a template in an article page, put the name of the template (without the "Template:" prefix) in double curly braces. Wherever that template reference is made, its text will appear. There aren't any practical restrictions in terms of where you include a template. You can put templates on their own line, in a paragraph, inside a list or table... doesn't matter.

As an example, if we put {{HelpAddContent}} on the next line, this is what we get:

The template page is not actually copied into your article. Instead, whenever the article is viewed, the page builder will substitute the template reference for the template's actual text. This means that changes can be made to the template to improve or fix it, and no changes need to be made to the articles that use it. The next time the article is loaded, the template's new appearance will show up.

Template Parameters[edit]

Let's say you wanted to create a template for displaying information about a sponsor, so you could include a standard "Sponsored by" box on every page of a wiki. If you had to create one template for each of many sponsors, it would become a real hassle and wouldn't be very modular.

Fortunately, templates have the ability to accept parameters. You can set up the template page to receive values from the articles that include them, and place those values in a predictable place. That allows you to use a template to provide a standard structure with different specific information.

Not every template requires parameters; the HelpAddContent one above is an example of one that doesn't need them.

Sending Parameter Values To The Template[edit]

Templates in MarketsWiki assign names to the various parameters they're expecting. When you use a template that's expecting parameters, you include the name of each parameter, an equal sign, and the value for that parameter.

For example, the template Infobox Midpage Sponsor requires two parameters:

caption_info   and

To properly use the template, you'd supply the caption that should appear, and the image file name for the logo, using the pipe "|" symbol to separate all the pieces, like this:

 {{Infobox Midpage Sponsor | caption_info=International Securities Exchange| 

That produces this box:

MarketsWiki is sponsored by
ISE logo2.jpg
International Securities Exchange

Because we are using names to send the values, you can put them in any order. You would get exactly the same box if you had flipped the parameters around, like this:

 {{Infobox Midpage Sponsor | sponsor_logo=ISE_logo2.jpg | 
   caption_info=International Securities Exchange}}

How do you know what parameters are expected? You can check the list at the end of this article. You can also look at the code for the templates. Every template that requires parameters should have a comment section inside to explain what the template wants to receive.

Creating Templates[edit]

Templates are considered part of the standard structure of MarketsWiki. As a general rule, contributing authors shouldn't create standard elements, at least not without a discussion with the MarketsWiki team.

If you see a need for a standard template, begin the discussion on Jon's Talk page.

Templates Available In MarketsWiki[edit]

Citation/Footnote Templates[edit]

For a complete description of footnote templates, see the bottom section in the article Using Citations.

Sponsorship Boxes[edit]

There should be a sponsor box on every page, oriented either on the right or left of the page according to aesthetic preference. If we have a sponsor, use a "Sponsor" template. If the page has no sponsor yet, use a "Need Sponsor" box. Available templates:

Template Name Function Parameters
Infobox Midpage Need Sponsor Creates a left-oriented box requesting sponsorship None
Infobox Midpage Need Sponsor Right Creates a right-oriented box requesting sponsorship None
Infobox Midpage Sponsor Creates a left-oriented sponsor box
  • sponsor_logo, the name of the logo image file
  • caption_info, the sponsor's name or other branding text
Infobox Midpage Sponsor Right Creates a right-oriented sponsor box
  • sponsor_logo, the name of the logo image file
  • caption_info, the sponsor's name or other branding text

Information Boxes[edit]

Information boxes exist to create data snapshots for companies, people and topics. They're not strictly required for people and general topics, but should be included for companies and other organizations.

Template Name Function Parameters
Infobox Company Creates a right-oriented company box
  • company_name, the full legal name of the company (required)
  • company_logo, logo image file name
  • foundation, year when company was founded
  • location, main company location
  • key_people, top one or few officers/producers
  • products, quick list of most important products/services
  • twitter, the company's Twitter id (e.g. JohnLothian)
  • homepage, web site for company
Infobox Person Creates a right-oriented box for a person's bio page
  • employer, Where the person works
  • job, Person's occupation, type of work, NOT their company
  • loc, Location in the world
  • name, Person's name (required)
  • pic, Picture. Syntax: personpic.jpg
  • twitter, the company's Twitter id (e.g. JohnLothian)
  • url, Person's web site

Utility Templates[edit]

Various templates for occasional use as needed.

Template Name Function Parameters
Disambig Standard introduction for a "disambiguation" page,

which identifies multiple topics with the same name.

HelpAddContent Alert box requesting that people contribute to this page. None
In Progress Flags an article as being actively updated over time by a contributor. The name of the person who is doing the update.
{{In Progress Jim Dandy}}
Reference Help Alert box requesting that people help update the footnotes and References section. None
Under Construction Alert box apologizing for the construction mess. None