Namespace Templates

Sometimes you might want that every page in a certain namespace is based on a common skeleton. For example, in the address namespace you could have an already prepared table, which only needs to be filled with data. This can be easily achieved with so called “namespace templates”. When a page is created, DokuWiki looks up whether there is a file _template.txt in that namespace and copies it into the edit field for the new page.

There is also support for templates called __template.txt (two leading underscores). These templates just work as the normal _template.txt files but are used in all namespaces below as well.

You can't edit the _template.txt through DokuWiki – only someone who can edit the files inside the DokuWiki folders (usually an administrator using FTP or WebDAV) can1).

One way to create the template file is to

There are a few replacement patterns you can use:

@ID@ full ID of the page
@NS@ namespace of the page
@PAGE@ page name (ID without namespace and underscores replaced by spaces)
@USER@ ID of user who is creating the page
@NAME@ name of user who is creating the page
@MAIL@ mail address of user who is creating the page
@DATE@ date and time when edit session started

In addition you may also use any strftime placeholder to insert the time of page creation in any format you like. If you want to use a literal % character in your template you need to double it. Please explain this further. If I add %Y in my template, it doesn't turn it into “2008”.

1) If you want to allow anybody to edit the template you can change its name to “template.txt” at around line 623 inc/common.php. Then any user with write access in the namespace can create a page called “template” in that namespace which will serve as the template.