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
- Sidebar - creates this sidebar.
- Stub - identifies a stub article.
- Disambig - identifies a disambiguation page.
- Frame - creates a frame around image with optional caption. Text will wrap around the image.
- Temperature conversion
- Distance/Speed conversion
- Km to miles - takes a distance or speed in km and displays as: 10 kph (6.2mph)
- Km to nm - ditto for nautical miles/knots
- Miles to nm - ditto for miles to nautical miles/knots
- Miles to km - ditto for miles to kilometers/kph
- nm to km - ditto for nautical miles/knots to kilometers/kph
- nm to miles - ditto for nautical miles/knots to miles/mph
- Sea Kayaking Destination - formats a sea kayak destination page for Places - e.g. The Massassauga Provincial Park
- Whitewater Destination - formats a whitewater destination page for Places - e.g. Leven
- References
- Book - formats a book page e.g. Inuit Kayaks in Canada
- Video - formats a video page e.g. Rolling With Maligiaq
- Magazine - formats a magazine page e.g. Sea Kayaker Magazine
To see a complete list of templates:
- click on Special pages (lower left toolbox)
- select All Pages
- use the drop down to select Namespace Template
- 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
- For full documentation on templates, please see: Wikimedia Template Documentation
- KayakWiki has implemented the Parser Functions extensions for templates.
[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.
- TemplateDocTop - Main template documentation portion
- TemplateDocTableHead - Parameter Table headers
- Parameter table content
- TemplateDocBottom - finish the documentation section.
- Template code.
For templates without parameters (see Template:Stub for an example), only the following three parts are required.
- TemplateDocTop - Main template documentation portion
- TemplateDocBottom - finish the documentation section.
- 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

