====== newpagetemplate Plugin ====== ---- plugin ---- description: Loads predefined page content from a given template author : Damien Regad, Jason Grout, Myron Turner email : dregad@mantisbt.org type : syntax, CLI lastupdate : 2023-10-19 compatible : Lemming, Anteater, Rincewind, Angua, Adora belle, Weatherwax, Binky, Hrun, Detritus, Elenor Of Tsort, Frusterick Manners, Greebo, Hogfather, Igor, Jack Jackrum, Kaos+ depends : conflicts : similar : plugin:templatepagename tags : editing, template, button, URL, POST downloadurl: https://github.com/turnermm/newpagetemplate/archive/refs/heads/master.zip sourcerepo : https://github.com/turnermm/newpagetemplate # https://github.com/jasongrout/dokuwiki-newpagetemplate/ bugtracker : https://github.com/turnermm/newpagetemplate/issues donationurl: https://github.com/sponsors/dregad ---- ===== Description ===== 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. In simple terms, you can create a page in your dokuwiki and then use that page as a template for new pages. The plugin has been extensively modified and integrated into the [[plugin:openas]] plugin by Myron Turner. The [[plugin:openas]] plugin and the [[plugin:addnewpage]] plugin provide techniques which support the ''newpagetemplate'' plugin. The [[plugin: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. ===== Usage ===== If a new page is created with the URL: doku.php?id=:mynewpage&do=edit&rev=&newpagetemplate=:pagetemplates:yourtemplate&newpagevars=@HI@,Howdy!;@NAME@,Joe then the '':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: newpagevars=key,value;key2,value2;key3,value3; See [[#configuration_options]] and [[#substitutions]] for a description of the standard and user replacements. ===Example of syntax for a template page== If you create a template page ''yourtemplate'' with this markup in '':pagetemplates:'' 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: &newpagevars=@HI@%2CHowdy You may find with use that there are others. ==== Substitutions ==== As with the ''_template.txt'' [[:namespace_templates|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 | ^ %a %d-%m-%y etc. | e.g. Thu 06-12-12. [[phpfn>strftime]] placeholders are replaced by page creation time | ===== Configuration Options ===== ^ 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. | The ''prettytitles'' patch was contributed by Matthias Bannach. ===== Version History ===== 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 [[https://github.com/jasongrout/dokuwiki-newpagetemplate/zipball/master|github]] ===== Alternate Interfaces ===== ==== openas ==== There is an alternate interface in the [[plugin:openas]] plugin which enables the creation of forms that pass the data to newpagetemplate. See the [[plugin:openas?#expanded_syntax_for_the_openas_format|expanded syntax section]]. === CLI === 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 [[:plugin:newpagetemplate:cmdline|newpagetemplate:cmdline]] for further details and the download link. ===== Bugs ===== See https://github.com/turnermm/newpagetemplate/issues ===== Discussion ===== See [[plugin:newpagetemplate:discussion|discussion page]] for some early discussion topics ===== Change Log ===== {{rss>https://github.com/turnermm/newpagetemplate/commits/master.atom date}}