Learn about DokuWiki
Learn about DokuWiki
Sometimes you might want to have every page in a certain namespace 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 a template file exists and it shows it within the editor window. The templates therefore are .txt files and should contain wiki markup.
Two kinds of template files can be used:
_template.txt, which are used in the current namespace.
__template.txt(two leading underscores), which work as the normal
_template.txtfiles apart from the fact they are used in all namespaces below as well (they are inherited).
If both (inherited and normal) templates are present in a namespace, the normal one is taken.
One way to create the template file is to
The content of the file is just standard wiki markup.
Inside of the file, you may also use some replacement patterns to make the template a little more dynamic.
|@ID@||full ID of the page|
|@NS@||namespace of the page|
|@CURNS@||last part of the namespace of the page|
|@PAGE@||page name (ID without namespace and underscores replaced by spaces)|
|@!PAGE@||same as above but with the first character uppercased|
|@!!PAGE@||same as above but with the first character of all words uppercased|
|@!PAGE!@||same as above but with all characters uppercased|
|@FILE@||page name (ID without namespace, underscores kept as is)|
|@!FILE@||same as above but with the first character uppercased|
|@!FILE!@||same as above but with all characters uppercased|
|@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|
|%a %d-%m-%y etc.||e.g. Thu 06-12-12. Strftime placeholders are replaced by page creation time|
|%%|| a literal
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.
You can't edit the
_template.txt through DokuWiki (only someone who can edit the files inside the filesystem folders (usually an administrator using FTP or WebDAV) can modify these files). There are three ways to accomplish this, though:
_templateinto another name e.g.
templatethat is allowed as normal editable wikipage.
NOTE: This section contains instructions for use on a Linux server and will not work on a Windows system.
This way, you can store your templates in a special namespace, and make symlinks for DokuWiki to find them. You can also choose to make a specific template non-editable by removing its particular symlink.
Another way is to create symlinks in the folder itself. Thus you create a
template.txt which is a symbolic link to the
_template.txt, in it's own namespace.
cd /var/www/html/dokuwiki/data/pages/namespace/something ln -s _template.txt template.txt
For these softlinks to work, you might need the FollowSymLinks option set for this directory in your webserver's configuration.
NOTE: This section contains instructions for use on a Windows server and will not work on a Linux system.
Open up command prompt (cmd.exe) on the server, and browse to the location you with there to be a template. Use the MKLINK command to create a symbolic link.
cd c:\inetpub\wiki\data\pages\namespace\something mklink template.txt _template.txt
Additional template features are implemented by plugins.
__templatein your choice via configuration manager. Has as defaults respectively
i_template. This plugin will let you choose normal wiki pages as template so that they are editable via the wiki interface.
~yourpagename.txtfor the page named
yourpagenamein the current namespace
~yournamespace.txtfor all pages in the subnamespace named
It may be interesting to have support for the
@GROUPS@ keyword to extend to the group list of the user creating the page (e.g. to specify a set of tags on a user's home page). The following patch implements it.
Index: dokuwiki-2009-02-14/inc/common.php =================================================================== --- dokuwiki-2009-02-14.orig/inc/common.php 2009-11-19 11:58:41.000000000 +0100 +++ dokuwiki-2009-02-14/inc/common.php 2010-01-05 10:17:35.000000000 +0100 @@ -840,6 +840,7 @@ '@USER@', '@NAME@', '@MAIL@', + '@GROUPS@', '@DATE@', ), array( @@ -855,6 +856,7 @@ $_SERVER['REMOTE_USER'], $INFO['userinfo']['name'], $INFO['userinfo']['mail'], + implode(" ", $INFO['userinfo']['grps']), $conf['dformat'], ), $tpl);
— Olivier Mehani 2010/01/05 10:19