Create Templates

Posted by Phil Chett on 29 Jul 2007 18:09, last edited by redmage909 on 22 Feb 2017 18:17

Tags: include template

rating: +12+x

Do not confuse this template documentation with that of LIVE template (_template). they are different animals :-)

What are templates?

If you are reading this How To… you have probably tinkered a bit with your own wiki in Wikidot. Among the things you have probably done is creating new pages and writing up some content in those pages. Every time you have added a new page, the editor has opened a blank sheet. You have written anything you thought interesting, and you have formatted it as you thought appropriate. Unknowingly to you, that blank page is a template (a default template) in Wikidot. This default template ''says'' something like this: Everytime a new page is added to a Wikidot site, open a blank page.

Imagine now that your wiki is about some specific topic, like meal recipes, or computer game characters. To keep the wiki tidy, you intend for each recipe or character to have its own page. However, you also envisage that the content in each page can be equally organized, for example according to fixed headings, perhaps with a table of contents at the top of each page, etc. This formatting is repetitive, and rewriting it every time you add a new page can become tiresome. A template can help you to write this formatting once but automatically use it in each new page you create. That is, you can "tell" your wiki to use your own template for each new page you or another contributor to your site creates.

Therefore, templates are pre-formatted pages that you can create and manage in order for you and your site contributers to use every time a new page is added to your wiki.

Two excellent examples of templates can be found at:
http://siliconcity.wikidot.com/template:herocharacter , a template which includes
http://siliconcity.wikidot.com/HeroBox of which all parameters such as {$origin}, {$archetype} or … will be replaced by actual values.

What do you need to create and manage templates?

Interestingly enough, you create and manage templates in two parts of your wiki:

  • The main side menu is where you add new pages, list all pages or search for given pages. Your templates are created and edited from here, as if it were another page in your wiki. To create a template, you add a new page in the manner it is shown later. To edit a template, you search for it (using List all pages, Search or Tags) and then edit it as you would edit any other page in your wiki.
  • Your site manager page/menu. This allows you to, for example, allocate a template as the default template for your wiki, set permissions, etc.

You can see your available templates in Site Manager » Page templates. Although if you were to check it up now, you will probably find that you only have a default template (which only provides you with a blank page!).

Creating templates step-by-step

Step one: add a new page

A template is created, modified and listed as any other page in your wiki. Therefore, using the New page button on the side menu bar, create a new page called, for example:

template:recipes

"template" is the category reserved for templates.
"recipes" is the name you wish to give it.

This will create a page entitled "Recipes", will open your editor, and will present you with a blank page for you to edit.

(Note: "Recipes", although pertaining to the category template, will be saved as "Recipes" in your list of pages. If you want to remind yourself that this is a template, you could also save it as template:template-recipes).

Step two: create your template

You can now type anything you want all new pages using this template to display (don't worry much now, you can always edit it later). So, for example, let's write down the following bullet points (you can format them as headings, for example):

  • Ingredients
  • Cooking time
  • Method
  • Serves

Save the page. This finishes your editing of the template.

Just for the sake of it, let's create another template called "characters". Again, in the New Page box on the side bar create a page named:

template:characters

Then enter some headings, such as:

  • Race
  • Armor
  • Talents

Save the page.

Step three: edit your templates

Now you have two new templates, one called Recipes and the other called Characters. If you List all pages, you will find both templates as pages, and you can re-edit those templates as appropriate. Any time you want to tinker, change or improve any of your templates, you can simply open its page and make the necessary changes. Then, save the page, and the changes will appear in any subsequent new page.

(Note: changes to templates only affect new pages, not all pages. Therefore, if you want your older pages to reflect the new changes, you will have to edit each page individually, and make those changes one by one!).

Step four: manage your templates

To manage how your wiki uses templates, you need to do so from your Site manager. Go to
Site Manager » Page templates

There you will see two boxes. The left one shows the Categories used in your site. The right one lists the Templates you have. You will now find recipes and characters as available templates. If you click on each template, you will see a preview underneath which tell you how each template is formatted.

An important aspect you have to manage is whether any contributor can change your templates or not. You probably don't want that to happen. However, unless you restrict others from so doing, they will be able to access your templates and change them. You can restrict such actions in Site manager. (Note: this will not prevent the contributor from changing the formatting of any page s/he edits. It only prevents her/him from changing the template)

(Note: you can also block the editing of your template other way. Once you have saved your template, click the +options button at the bottom of the page, then the block option).

Another thing that you can do in Site manager is to assign which template to use as default template every time your contributors create a new page).

What is a template good for?

Well, exit Site Manager and go back to your wiki. Create a new page in the New page box on the side bar.
Have a look in the edit box. You should now see a new drop down box, which should display the templates you have, as well as the template you have selected as the default template for the page:

Initial template: no template (blank page)
recipes
characters

Click on the template that you wish to use and you will see that the text that you have included in the selected template (e.g. recipe headings) will automatically appear in your editor.

Job Done!!


Assigning templates to categories

You might find it useful to use a particular template for a particular category. For example, let's say that you have created a template for Recipes, as we have illustrated above (steps 1 to 3). Furthermore, every time a new recipe is added to your wiki, you want it to use that template, so you have set up it as your first template in Site manager, as well (step 4).

So far, so good. Except for two things. Every time you add a new page, Wikidot will create such a page in the "_default" category, and all these pages will always open with the Recipes template on it. The implications are the following:

  • all pages are allocated to the same "_default" category. This may prove limiting later on (for example, for setting permissions, etc) because you can only do this for the "_default" category as a whole. Instead, using a specific category: for recipes will give you more management flexibility.
  • all pages open with the template Recipes as its first template. If you create another page, for example a system: page, you need to change template. This is just a click away but, if you have different templates, you may as well prefer your page to open with the appropriate template.

Therefore, linking (or assigning) particular templates to particular categories may help you manage your site better as well as making things easier for your contributors.

How do you do this? Let's describe a step-by-step method below.

Step one: create your category if you don't have one yet

The first step is to create a category Food so that you can manage all this pages as a group. Check How to create categories for this step.

By the time you have finished with this step, you should have several things done:

  • you should have created a category (e.g. a Food category).
  • you should have re-allocated all relevant pages to this category by Renaming them.
  • you may have also use Site manager to manage this particular category.

So far, however, each new page pertaining to this category has to be named manually (e.g. by naming it as Food:Lobster a la Perpignon).

For the time being, however, let's say we are creating a category from scratch. Thus, do the following:

Step two: create the Add a new page function for your category

The second step is to set up an Add a new page function so that all new pages created with this function are automatically put into the Food category. Check Assigning pages to categories automatically in How to create categories for this step.

By the time you have finished with this step, you should be able to create a new page in the appropriate category without the need to write categoryname: before the name of your new page.

Step three: create your template if you don't have one yet

The third step is to create a template for Recipes so that the template uploads automatically every time you select it from your editor (and, later, every time you create a new page in the Food category).

By the time you have finished with this step, you should have several things done:

  • you should have created a template (e.g. a Recipes template).
  • you should have edited the template as you see fit.
  • you may have used +options to manage features of this template.

Following with our example from scratch, let's create a template as follows:

  • Create a template called Recipes by way of creating a new page called template:recipes (see How to create templates).

Step four: link your template to your category using Site manager

This fourth step is the one that actually links a particular template to a particular category.

  • Go to Site manager - Page templates
  • Search for your category first and click on it to highlight it. When it is highlighted, you know that that particular category has been selected.
  • Go to the template box and click on the template you want to be automatically uploaded every time you create a new page in that category. When it is highlighted, you know that that particular category has been selected.
  • Save your changes.

By the time you have finished with this step, you have effectively assigned a particular template to a particular category. Notice, however, that both templates and categories are independent of each other. When you assign a template to a category, Wikidot's editor automatically uploads that template to each new page it opens within that particular category. Notwithstanding this, all remaining templates are still available as alternative choices and can, thus, be selected.

Following with our example from scratch:

  • Open Site manager - Page templates
  • Search in the box where categories are listed (left box), and click on Food.
  • Search in the box where templates are listed (right box), and click on Recipes.
  • Save

From now on, every time you create a new page in the category Food it should upload the Recipes template automatically.

Still having Problems?

If for some reason your new page button is not working right, try this:

If you are still having problems you might want to try the help area on this site.

Links

Sites that use the "template / include" technique:

A complete other template usage is the "live" template :

Authors

Phil ChettPhil Chett. Please visit his/her userPage.

JDPerezgonzalezJDPerezgonzalez. Please visit his/her userPage.


Related articles

Comments

Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.