Table of Contents
This plugin loads into the edit window a template specified in the
newpagetemplate parameter of the $_REQUEST global. Effectively, this means that you can invoke a template, similar to the namespace template pages, either in the URL or in a POST form coded to create a new page. The plugin has been extensively modified and integrated into the openas plugin by Myron Turner.
The openas plugin and the addnewpage plugin provide techniques which support the
newpagetemplate plugin. The openas plugin includes a simple method of creating a form designed for use with the
newpagetemplate plugin, making it possible for each user to assign unique values to the template's variables.
If a new page is created with the URL:
:pagetemplates:yourtemplate template is pasted into the edit window with all macro substitutions completed. If the
standardreplace configuration option is true, then the substitutions detailed below are made. If the
userreplace configuration option is true, then you can pass in additional macros and their substitutions using the
newpagevars option, as illustrated in above example url. In that example, wherever the template has
@HI@, it will be replaced with
Howdy! The format for newpagevars is:
Example of syntax for a template page
If you create a template page
yourtemplate with this markup in
This page is: @ID@ @HI@ @NAME@
And if you paste the above URL into your browser's location bar, you will get a page in your browser that looks something like this:
This page is: mynewpage Howdy! Joe
@ID@ is one of the 'standardreplace' macros and
@HI@ is a 'userreplace' macro.
How to create a link using wiki syntax
Is it possible to use standard wiki-link syntax for this? For eg. like:
[[:mynewpage?do=edit&rev=&newpagetemplate=:pagetemplates:homepagetemplate&newpagevars=@HI@,Howdy!|New page with template]]
Yes, you can do this. But you will have to substitute some url-encoded characters. In particular, the comma must be represented as
%2c. So this would give you:
You may find with use that there are others.
As with the
_template.txt namespace templates, the following variables are replaced in your template.
|@ID@||full ID of the page|
|@NS@||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|
|@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|
|userreplace||Replace user defined macros as explained above in usage|
|standardreplace||Replace standard macros as listed above in substitutions|
|prettytitles||Replace underscores with spaces in the following standard macros @!PAGE@, @!!PAGE@,@!PAGE!@|
|skip_unset_macros||Remove macros which have no substitution values, so that they don't appear in the newly created page.|
prettytitles patch was contributed by Matthias Bannach.
This plugin was originally written by Jason Grout. It was later modified by: Sergio (1 Apr 2007), an unidentified author, and Niko Paltzer (15 Jan 2010). The original version was not compatible with current Dokuwiki distributions (post-2010-03-10). The current version of
newpagetemplate supports all current distributions of Dokuwiki and is backwardly compatible with distributions going back to 2006.
The original version of
newpagetemplate has security concerns which have been addressed in the current distribution. In the earlier version, ACL is not checked before the template page is accessed, which means that anyone with access to the wiki can access the template page. A user with enough rights in one part of the wiki might access any page in the whole wiki. Moreover, user input inserted with the
userreplace option was not sanitized, making it possible to inject code with malicious intentions.
If you wish to use the original version it is available from github
There is a module of
newpagetempate that implements DokuWiki's CLI protocol. This enables the plugin to be run from the command line and to process multiple files and templates from one command. In addition to command-line access it also provides an admin plugin to facilitate working with the command line features. See newpagetemplate:cmdline for further details and the download link.
See discussion page for some early discussion topics
- updates version (2021-05-11 15:11)
- Merge branch 'master' of github.com:turnermm/newpagetemplate (2021-05-11 15:04)
- Adds facility to handle both hogfather and pre-hogfather utf8 functio… (2021-05-10 17:06)
- updates version (2020-12-30 18:20)
- Replaced create_function in array_map (action.php) with anonymous fun… (2020-12-30 18:12)
- updates plugin.info.txt (2020-09-28 15:38)
- update info (2018-12-11 15:38)
- Update info (2018-05-22 17:44)