Translations of this page?:

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

  • use the wiki to save a page with the content that you want to use as a template into the appropriate namespace
  • use FTP or WebDAV to make a copy of it in the same folder and rename it, then
  • use the wiki to delete the original page.

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.

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.
 
wiki/namespace_templates.txt · Last modified: 2008/05/04 21:45 by andi
 
Imprint Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsTranslate