DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:newpagetemplate

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
plugin:newpagetemplate [2020-09-28 15:31] – [newpagetemplate Plugin] turnermmplugin:newpagetemplate [2024-03-08 09:19] (current) – old revision restored (2024-03-08 09:07) dregad
Line 3: Line 3:
 ---- plugin ---- ---- plugin ----
 description: Loads predefined page content from a given template description: Loads predefined page content from a given template
-author     : Myron Turner; Jason Grout +author     : Damien Regad, Jason Grout, Myron Turner 
-email      : turnermm02@shaw.ca +email      : dregad@mantisbt.org 
-type       : syntax +type       : syntax, CLI 
-lastupdate : 2018-05-22 +lastupdate : 2023-10-19 
-compatible : lemming,anteater,rincewind,angua,adora belle,weatherwax,binky,hrun,detritus,"Elenor Of Tsort""Frusterick Manners",Greebo,hogfather+compatible : LemmingAnteaterRincewindAnguaAdora belle, WeatherwaxBinkyHrunDetritus, Elenor Of Tsort, Frusterick Manners, Greebo, Hogfather, Igor, Jack Jackrum, Kaos+
 depends    : depends    :
 conflicts  : conflicts  :
 similar    : plugin:templatepagename similar    : plugin:templatepagename
 tags       : editing, template, button, URL, POST tags       : editing, template, button, URL, POST
-downloadurl: https://github.com/turnermm/newpagetemplate/zipball/master+downloadurl: https://github.com/turnermm/newpagetemplate/archive/refs/heads/master.zip
 sourcerepo : https://github.com/turnermm/newpagetemplate # https://github.com/jasongrout/dokuwiki-newpagetemplate/ sourcerepo : https://github.com/turnermm/newpagetemplate # https://github.com/jasongrout/dokuwiki-newpagetemplate/
 bugtracker : https://github.com/turnermm/newpagetemplate/issues bugtracker : https://github.com/turnermm/newpagetemplate/issues
-donationurl: http://mturner.org/userfiles/donate.php+donationurl: https://github.com/sponsors/dregad
 ---- ----
  
 ===== Description ===== ===== 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. +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. 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.
Line 27: Line 28:
  
 If a new page is created with the URL: If a new page is created with the URL:
-  doku.php?id=:mynewpage&do=edit&rev=&newpagetemplate=:pagetemplates:yourtemplate&newpagevars=@HI@,Howdy! +  doku.php?id=:mynewpage&do=edit&rev=&newpagetemplate=:pagetemplates:yourtemplate&newpagevars=@HI@,Howdy!;@NAME@,Joe 
-then the '':pagetemplates:yourtemplate'' page is pasted into the edit window.  If the "standardreplaceconfiguration option is true, then the substitutions noted below are performed.  If the "userreplaceconfiguration option is true, then you can also replace ''@HI@'' with ''Howdy!'', as this substitution was passed in newpagevars.  The format for newpagevars is:+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;    newpagevars=key,value;key2,value2;key3,value3;
 See [[#configuration_options]] and [[#substitutions]] for a description of the standard and user replacements. See [[#configuration_options]] and [[#substitutions]] for a description of the standard and user replacements.
Line 45: Line 46:
   Howdy! Joe   Howdy! Joe
  
-''@ID@'' is one of the 'standardreplace' macros and ''@HI@'' is a 'userreplace' marcro.+''@ID@'' is one of the 'standardreplace' macros and ''@HI@'' is a 'userreplace' macro.
        
 === How to create a link using wiki syntax===    === How to create a link using wiki syntax===   
Line 63: Line 64:
 As with the ''_template.txt'' [[:namespace_templates|namespace templates]], the following variables are replaced in your template. As with the ''_template.txt'' [[:namespace_templates|namespace templates]], the following variables are replaced in your template.
  
-^ @ID@              | full ID of the page                                                                  +^ @ID@              | full ID of the page                                                                    
-^ @NS@              | namespace of the page                                                                +^ @NS@              | namespace of the page                                                                  
-^ @PAGE@            | page name (ID without namespace and underscores replaced by spaces)                  +^ @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 uppercased                                  
-^ @!!PAGE@          | 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                     
-^ @!PAGE!@          | same as above but with all characters uppercased                                     +^ @!PAGE!@          | same as above but with all characters uppercased                                       
-^ @FILE@            | page name (ID without namespace, underscores kept as is)                             +^ @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 the first character uppercased                                  
-^ @!FILE!@          | same as above but with all characters uppercased                                     +^ @!FILE!@          | same as above but with all characters uppercased                                       
-^ @USER@            | ID of user who is creating the page                                                  +^ @USER@            | ID of user who is creating the page                                                    
-^ @NAME@            | name 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                                        +^ @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                                                
-@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 %d-%m-%y etc.  | e.g. Thu 06-12-12. [[php>Strftime]] placeholders are replaced by page creation time  |+
  
  
Line 95: Line 95:
  
 If you wish to use the original version it is available from [[https://github.com/jasongrout/dokuwiki-newpagetemplate/zipball/master|github]] 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 ===== ===== Bugs =====
 See https://github.com/turnermm/newpagetemplate/issues See https://github.com/turnermm/newpagetemplate/issues
 +===== Discussion =====
 +See [[plugin:newpagetemplate:discussion|discussion page]] for some early discussion topics
 ===== Change Log ===== ===== Change Log =====
  
Line 104: Line 115:
  
    
-===== Discussion ===== 
- 
-> Could anybody provide me a simple description or example for the usage of the plugin in combination with 'addnewpage'? 
-> Thanks, Matt 
->> See the [[plugin:openas|openas]] plugin 
- 
----- 
- 
-> When accessing a non-existing page you're provided with a text: 
-> //This topic does not exist yet \\ 
-You've followed a link to a topic that doesn't exist yet. If permissions allow, you may create it by using the Create this page button // \\ 
-> It would be nice to add text where the user can choose from different templates, your plugin would then provide the URL to match the name of the page and the user has choice from different templates. Or am I missing something here ? 
- 
->> I have a same question. Can anybody explain me how to use a new page template when adding a page. I am new to PHP and don't know anything. Your help is highly appreciated.  
->> Thanks, George 
- 
----- 
- 
-This plugin helped me quickly setup template pages for my students to work on, today.  Thanks!  The only inconvenience was that I had to create a unique link for each student to follow.  For example: 
-<code> 
-  * [[:courses:isci422:projects:Ima Student:start?do=edit&rev=&newpagetemplate=:courses:isci422:projects:template|]] 
-  * [[:courses:isci422:projects:Anutha Student:start?do=edit&rev=&newpagetemplate=:courses:isci422:projects:template|]] 
-  * ... 
-</code> 
-It would have been even better if I could have created a single link with a substitution in the linked namespace, like: 
-<code> 
-[[:courses:isci422:projects:@NAME@:start?do=edit&rev=&newpagetemplate=:courses:isci422:projects:template|]] 
-</code> 
-I don't know if it's feasible but it sure would be cool :-) --- [[user>rikblok|Rik Blok]] //2011/11/08 05:42// 
- 
-> The problem here would be where to get the substitutions from. Somewhere there would have to be a list of names for @NAME@ and some  way to identify which name to use for the substitution.   
- 
- 
->> I tried to use your conception and for substitutes was used bureaucracy+pagemod plugins. I have noticed some drawback. After creating link on new page it is possible just to open for editing it. For end users it is not suitable to delete this part of code (start?do=edit&rev=&newpagetemplate=:courses:isci422:projects:template) 
- 
->>> I may not have explained myself clearly.  I'd like [[#substitutions | substitutions]] like ''@NAME@'' also to work in urls created by newpagetemplate.  For example, if the user 'Ima User' clicks the link<code> 
-[[:namespace:@NAME@:start?do=edit&rev=&newpagetemplate=:courses:isci422:projects:template|]] 
-</code>then a new page is created for editing at '':namespace:Ima User:start'' Does that make sense?  Thanks. --- [[user>rikblok|Rik Blok]] //2013/01/25 20:31// 
- 
->>>> There are several problems with this.  First, with a url like this, the server couldn't know where to direct the request, since the address is initially incomplete.  The request is sent out before ''@Name@'' can be filled in.  But what I missed in my earlier response is that these would be illegal names.  And Dokuwiki when it parses the file, will remove the @-signs, and so you will end up  with '':namespace:NAME:start''. 
- 
-This is a bit late in the day, but you can deal with the above problem using the [[:plugin:goto#updated_version|the goto plugin]]. 
- 
----- 
- 
-How does the interaction with existing namespacetemplates work? 
-> There should be no interaction.   The templates for newpagetemplate are regular Dokuwiki pages, not Dokuwiki templates.  That is, they are named ''my_template.txt'' and not ''__my_template.txt'' or  ''_my_template.txt'' You should probably keep them in a directory which is protected by ACL from access by unauthorized users. 
- 
->>Thank you! 
- 
----- 
- 
-I am trying to run newpagetemplate together with addnewpage. Not being fluent in php and programming, I don't know how to generate a patched version of the addnewpage/syntax.php. I tried to patch it manually. But as soon as I include this patched syntax.php each request to my portable server to load my dokuwiki into the firefox window fails. How to do it properly? The link with the patched code in the addnewpage-discussion does not lead to such a file anymore. 
-> See the [[plugin:openas|openas Plugin]].  This will let you use the newpagetemplate plugin to create a Dokuwiki internal link that opens a new page with your template substitutions. 
- 
->> I have a wikipage named "materialdata". I want to provide a template for all new pages created by links from that page (or alternatively by an addnewpage-dialogue on that page - in that case the template would include the tag "material", so that the new pages will be displayed on the materials page by <nowiki>{{topic>material}}</nowiki> ). My problem is: The names of the new pages are given by the users. I would like to keep the interaction as simple as possible as most users in our wiki tend to use a wysiwyg editor. How can I use the openas-Plugin to provide a template for a page named by the user? 
- 
->>> You can't.  The simplest solution would be to create a standard Dokuwiki template with double underscores, so that it controls all subdirectories beneath it.  Then with the addnewpage plugin, let your users open new pages in the namespace controlled by that template. With addnewpage, you can do this: 
-   {{NEWPAGE>namespace}}  
-Then your users will get a text box in which to enter the name of a page which will open in my_namespace.  If you have a template in my_namespace, then when the page is created, it will use that template.   If you use the double underscore version of the template then the user can a page in a subdirectory of that namespace and still have the template operative. 
- 
->>>>Sadly we tried to avoid namespaces as we wanted to make linking (across subjects, even to the materialdata pages) as simple as possible for the users. Does the combination of addnewpage and newpagetemplate not work? 
- 
->>>>> Then use this: 
-    {{NEWPAGE>:}} 
-That will link to a page in the root directory.  Then you can put your template in the root.  
->>>>> Both the addnewpage and the newpagetemplate plugins do the same thing, insofar as they both link to a new page.  The difference is that newpagetemplate implements a template in the url.    
->>>>> If you have further questions raise them on the [[http://forum.dokuwiki.org|forum]].  You might find solutions there. 
  
->>>>>>Thank you very much! 
plugin/newpagetemplate.1601299911.txt.gz · Last modified: 2020-09-28 15:31 by turnermm

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