About Templates

From KayakWiki

Templates are a great feature in Mediawiki. They allow you to create a bit of information that can be included anywhere on any page just by referring to the template name encased in double parentheses: {{template name}}. In addition, a template can contain categories which means that the page will automatically be included in a category - the pages for Places, for example, all contain the Destinations category, freeing the writer of the page from having to remember to include the category and ensuring that all destinations are properly categorized. Explore templates and you'll find that they are quite useful at making efficient use of resources.

Key Templates


To see a complete list of templates:

  1. click on Special pages (lower left toolbox)
  2. select All Pages
  3. use the drop down to select Namespace Template
  4. click the Go button.

This will display the KayakWiki Template List.

[edit] Non-parameterized Templates

If you have a part of a page that should appear on more than one page and a link to another page is not appropriate, create a template for the common part and include it in other pages using the template name. That will ensure that the text is not duplicated and if a change must be made, it is only made in one place - if the template is changed (to correct a spelling error, for example) the change is automatically included wherever the template is used.

[edit] Parameterized Templates

Of particular note is the fact that a template can take parameters. Parameterized templates allow one to create a standard method of formatting information while providing the template user with the ability to insert different content. The Sidebar template is an example. It can be used to create a sidebar with a title and content. The colours of the title bar and content area can be selected by the user and the size of the sidebar can be set as well.

In general, the way you use a parameterized template is to include in your page something like:

{{Template name
|FirstParameter=some value you provide
|SecondParameter=some other value you provide
}}

The wiki will take the parameter values you provide and format the portion of the page defined by the template and display the result.

In addition, the templates are documented using standard, parameterized templates. That means if you can figure out how to use one template, you should be able to use any of them.

[edit] How to create a template

[edit] Creating a Documented KayakWiki Template

In order to create a template that is documented, KayakWiki has three templates to support template documentation. By ensuring that a template is documented, it is more likely to be used and understood by novice KayakWiki contributors.

Note that there are five parts in a documented, parameterized template.

  1. TemplateDocTop - Main template documentation portion
  2. TemplateDocTableHead - Parameter Table headers
  3. Parameter table content
  4. TemplateDocBottom - finish the documentation section.
  5. Template code.

For templates without parameters (see Template:Stub for an example), only the following three parts are required.

  1. TemplateDocTop - Main template documentation portion
  2. TemplateDocBottom - finish the documentation section.
  3. Template code.

If you are at the point where you're creating a template, you probably know a lot about the wiki and markup techniques. It may be easiest for you to look at another template and see how these documentation templates are used. It would certainly be useful to do so to augment your understanding of these documentation templates and templates in general. Try Template:Book, for example.

If you look at TemplateDocTop, you'll see all the bits you need to use to create a documented template. You can copy and paste the template info from that page and create a new template. TemplateDocTop is documented with TemplateDocTop and the other documentation templates