++ Templates

Templates can be used to give an already prepared content as starting point to new pages.


+++ Using templates explicitly

On a newly created page, open the context menu (right click) on the text editor and choose in the "Use Template" submenu one of the offered pages as template whose content is copied to the newly created page. If the desired template page is not listed, choose "Other..." and select the page from a dialog.

The list of pages suggested as templates in the context menu is defined by an option, see [OptionsDialog#*Template page names reg. exp.*].

If a new page was modified already the context menu only offers an item "Use Template..." to get to the selection dialog. You should be aware that choosing a template there overwrites the current content of your page!


+++ Using templates implicitly by attributes

If a non-existing page has one parent which has a "template" attribute and there is no contradictory "template" attribute on one of the other parents (if any), the initial content of the new page will be taken from the page pointed to by the attribute.

The new page will (as always) only be created effectively after it is modified in some way.


Example:

Let's assume you want to record things you have bought,
each article on it's own page.


So at first create a template page: BoughtTemplate.

Then define this as a root page which uses the template:
[template: BoughtTemplate].

Be sure to save the wiki now because template pages will always taken as they are stored in the database, not as they are written in an editor.


Now you can create subpages:

    * ArticleFoobaromatic (this is already created)
    * ArticleStopAndGoer (go to this to see the template)
    * NotBoughtAlsoTemplate (or to this page)



You can enhance this example using [FormPages].


++++ Automatic heading replacement

As you might have noticed in the above examples, the heading at the top of the newly created pages was set automatically according to the name of the page like you are used to it for new, non-templated pages.

If you instead want to keep the heading of the template or don't want a heading at all, you can write \[template_head: manual] on the template page (in the example this is BoughtTemplate).

If you want to disable the automatic heading replacement for all templates of a wiki, you can place \[global.template_head: manual] on an arbitrary page of the wiki. To activate then the heading replacement for a particular template, use \[template_head: auto] on the template page.

