Creating a template
Before proceeding with the tutorial you need to:
|
A three-step process
Creating and using templates is a three step process:
- First you need to create a new template page;
- Then you need to generate the content for your template and save the template page;
- Finally, you need to insert a reference on your content pages in the main wiki namespace to call the content from your template.
Creating a template page
To create a template you need to create a page with Template: as the first part of the name. Up to now, we have created new pages in the wiki by making a link in some content to a page that doesn’t exist yet, then following the resultant red link to edit the new page (see for example: Creating new pages).
Templates are a little different because we are not really creating a link to the template itself, but will reference it on an existing content page. So we first need to create the template page before we can use it on a content page.
The easiest way to create a new template is to manually enter the name of the template into the URL bar of our browser after the http://www.wikieducator.org/ part, then either hit enter or the Go button. Like this:
The purpose of this activity is to create your first template page in the wiki.
|
Inserting a reference to call your template on a content page
Your template is just like any other wiki page and can contain any wiki markup or HTML code. In the previous activity you saved a temporary text which you can use to test whether your template is working. On the wiki page where you want to call the content saved in your template, you enter the name of your template between two curly braces. So for example, if the name of your template was Gardening_Nav, you would enter the following syntax on the relevant content page:
- {{Gardening_Nav}}
The purpose of this activity is to test whether your template is functioning properly.
|
- It is standard practice to include the navigation template at the top of your content page.
- The name of your template is case sensitive so you must use the exact capitalisation and lowercase letters used when you saved your template;
- If you can't find or remember the name of your template, click on the "my contributions" link at the top of your browser. Look for the most recent page you edited in the Template namespace;
- You can insert the call for a template on any content page by inserting the same syntax, i.e.: {{Name_of_your_template_goes_here}}
- In the next section of the tutorial we will replace the temporary text with the syntax required to set up a navigation template.
WikiEducator has prepared special navigation templates to simplify implementation and to encourage a consistent look and feel of our content pages. These special templates are easier to use because you can cut and paste the syntax without needing to worry about more complex html formatting. We have two generic template formats, so before you proceed you should decide on the type of navigation template you want to use:
- Navigation for project nodes or community hubs in WikiEducator (like the Learning4Content initiative) -- In this case you should proceed with section on templates for project and community nodes;
- Navigation for structured content with sections and subsections (like the navigation used for Developing a teaching resource -- In this case you should continue with the section on templates for structured content.