Creating Page Templates

This is an advanced topic. You must be at least this ----> tall to read.

Why would I want to use a Template?

Normal pages on AllAbout are freeform. You type your page content in one great big text box, putting headers and so on wherever you want. This is fine when you're creating lots of different kinds of pages. It's not so much fun when you're making lots of the same kinds of pages, like recipes.

Recipes have things in common with each other, such as a list of ingredients and a set of directions. A recipe template would allow you to build an input form with fields called "Ingredients" and "Directions" and so on. The template would take the information in those fields and create a nicely formatted page with the appropriate headers.

This saves a lot of time when entering recipes, and ensures that all recipes have a common appearance.

What is a Template?

A template is a page on AllAbout with at least two keywords. The first keyword must be the special keyword: Special:Template. The second keyword describes the particular sort of template, and should be similar to this: Template:Recipe.

The template itself is a normal AllAbout content page with headers and formatting. It also has, instead of regular content, special commands embedded in it to describe the fields that make up the template.

A Sample Template

We'll continue the Recipe example because it is simple and straightforward. Here is a template for a simple recipe with ingredients and directions:

= Recipe Ingredients

Here are the ingredients you'll need:


= Directions

Step-by-step directions:


As you can see, the template has two header lines, a little bit of text, and two field names surrounded by double % marks.

The field names represent the data that you'll type into the recipe page when the template is assigned to it. When you edit a Recipe page, instead of the big "Page Text" text box, you'll get two smaller text boxes, labeled "ingredients" and "directions".

When the page is shown to the user, they'll see the headers, the text, and then the ingredients and directions right where they belong -- without you having to type them over and over.

How do I place a Template on a Page?

To use a template on a page, include the Template:Recipe (or whatever you called it) keyword in the page. Since that keyword is also used on another page with the Special:Template keyword, AllAbout knows to apply the template.

Changing a Template

You can change a template even after it has been used in other pages. This can be to add more formatting, rearrange the fields, or to even add other fields. Be sure, however, to keep the NAMES of your fields the same. If you change the field names, you'll have to go back to all the pages that use that template and fix the field data.

Advanced Template Features

Field Size

To change the size of the edit area for a field, specify how many lines of text should be presented after the fieldname with a comma:

  • %%comment,10%%.

That would make the field labeled comment be ten lines high.

Field Instructions

You can add instructions about the field that's shown to the right of the field when editing the data by appending it after the fieldname (and/or field size) with a vertical bar character, like this:

  • %%price,1|Enter price as one to three dollar signs, representing "inexpensive" "moderate" or "luxury"%%

That would create a one-line high field named "price" with some explanatory text next to it to help the person filling out the form.

Optional Areas

If you enclose portions of your template in double parentheses, like these: (( )) , the portion of the template inside the parentheses will only be drawn if the fields used inside the parethesis are non-blank.

This makes it easy to build versatile templates and entry forms that can handle a variety of situations without having ugly pages with lots of blank headings for fields that simply don't apply.

How Templates Really Work with regards to Keywords

The rule for finding a template to apply to a page is as follows:

  • All of the keywords on the template (except Special:Template) must appear on the page.
  • If more than one template qualifies, pick the most specific one -- the one with the most keywords.
  • If there are multiple templates still matching, then (right now) I have no idea what happens. But in the future, the system will review keyword counts.

To use the recipe example again, the way the current Recipe Site works, the template has these keywords: Special:Template Site:Recipes Recipe. Thus, the template matches pages with the Site:Recipes Recipe keywords, without having to create a special template-specific keyword like Template:Recipe.

However, there's no shame in using a template-specific keyword when you want to, or when you need to, to specifically reference a certain template.

More Template Goodness

The following special tokens work in templates as described. They are most useful when creating list templates, but can be used otherwise.

  • 1 Makes a small "edit" link to the page.
  • ##created-date## Displays the date the page was created.
  • ##modified-date## Displays the date the page was last modified.
  • ##title## Displays the title of the page.
  • ##keywords## Displays the keywords of the page.
  • ##keywords,keywords to omit## Displays keywords except those appearing after the comma.
  • ##object## Shows the page number of the page. Useful in creating links, e.g. [##object##] makes a link to the page.
  • ##comments## Allows on-page comments
  • ##commentform## Builds a comment form onto the page itself.
All content on is the property and responsibility of the contributor. Don't steal. Use your head.