DokuWiki

It's better when it's simple

User Tools

Site Tools


namespace_templates

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
namespace_templates [2019-01-25 17:42] – [Plugins] Dr-Yukonnamespace_templates [2023-08-24 11:25] (current) – [Troubleshooting] 212.201.117.6
Line 1: Line 1:
 ====== Namespace Templates ====== ====== Namespace Templates ======
  
-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"+Dokuwiki supports scaffolding. 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. 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.
  
 ===== Template files ===== ===== Template files =====
 +
 Two kinds of template files can be used: Two kinds of template files can be used:
  
Line 11: Line 12:
   * ''%%__%%template.txt'' (two leading underscores), which work as the normal ''_template.txt'' files apart from the fact they are used in all namespaces below as well (they are inherited).   * ''%%__%%template.txt'' (two leading underscores), which work as the normal ''_template.txt'' files 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.+If both (inherited and normal) templates are present in a namespace, the normal one is used, when a new page is created.  
 +**Note:** Any changes to your template files will only take effect for new pages you create in that namespace.
  
-One way to create the template file is to+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 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 rename it as _template.txt, then +  - use FTP or WebDAV to rename it as _template.txt
-  - Note: ((These changes only apply to new pages that you create in the namespace.))+
  
 ===== Syntax ===== ===== Syntax =====
Line 25: Line 26:
 Inside of the file, you may also use some replacement patterns to make the template a little more dynamic. 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                                                                    | +^ @ID@              | full ID of the page                                                                    | 
-^ @NS@     | namespace of the page                                                                  | +^ @NS@              | namespace of the page                                                                  | 
-^ @CURNS@  | last part of the namespace of the page                                                 | +^ @CURNS@           | last part of the namespace of the page                                                 
-^ @PAGE@   | page name (ID without namespace and underscores replaced by spaces)                    | +^ @!CURNS@          | same as above but with the first character uppercased                                  | 
-^ @!PAGE@  | same as above but with the first character uppercased                                  | +^ @!!CURNS@         | same as above but with the first character of all words uppercased                     | 
-^ @!!PAGE@ | same as above but with the first character of all words uppercased                     | +^ @!CURNS!@         | same as above but with all characters uppercased                                       
-^ @!PAGE!@ | same as above but with all characters uppercased                                       | +^ @PAGE@            | page name (ID without namespace and underscores replaced by spaces)                    | 
-^ @FILE@   | page name (ID without namespace, underscores kept as is)                               | +^ @!PAGE@           | same as above but with the first character uppercased                                  | 
-^ @!FILE@  | same as above but with the first character uppercased                                  | +^ @!!PAGE@          | same as above but with the first character of all words uppercased                     | 
-^ @!FILE!@ | same as above but with all characters uppercased                                       | +^ @!PAGE!@          | same as above but with all characters uppercased                                       | 
-^ @USER@   | ID of user who is creating the page                                                    | +^ @FILE@            | page name (ID without namespace, underscores kept as is)                               | 
-^ @NAME@   | name of user who is creating the page                                                  | +^ @!FILE@           | same as above but with the first character uppercased                                  | 
-^ @MAIL@   | mail address of user who is creating the page                                          | +^ @!FILE!@          | same as above but with all characters uppercased                                       | 
-^ @DATE@   | date and time when edit session started                                                | +^ @USER@            | ID of user who is creating the page                                                    | 
-^ %a %d-%m-%y etc. | e.g. Thu 06-12-12. [[phpfn>strftime]] placeholders are replaced by page creation time | +^ @NAME@            | name of user who is creating the page                                                  | 
-^ %%       | a literal ''%'' character appears in your template                                     |+^ @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. [[phpfn>strftime]] placeholders are replaced by page creation time  
 +^ %%                | a literal ''%'' character appears in your template                                     |
  
  
Line 90: Line 94:
   * [[plugin:Headerfooter]] Plugin adds header text or footer text to pages only when they are displayed.   * [[plugin:Headerfooter]] Plugin adds header text or footer text to pages only when they are displayed.
  
-===== @GROUPS@ support ===== +==== Troubleshooting ====
- +
-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. +
- +
-<code unidiff> +
-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); +
- +
  
-</code>+Problem: An unexpected error occurs "no timestamp" when server (Linux Ubuntu) cannot write the directory ''/dokuwiki/data/pages/namespace''. This might happen, when the namespace directory is created by the admin as ''<root>'' in order to put the namespace template file in ''/dokuwiki/data/pages/namespace/'', before creating the first page.
  
- --- //[[shtrom-doku@ssji.net|Olivier Mehani]] 2010/01/05 10:19+Solution: Create a dummy page, like so: ''yourserver/doku.php?id=namespace:dummy&do=edit''. This allows DokuWiki to create the namespace directory under own control and assures full write permissions for DokuWiki on the created directory.
namespace_templates.1548434533.txt.gz · Last modified: 2019-01-25 17:42 by Dr-Yukon

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki