Allow quickly creating multiple pages from a user-supplied template.
PkTemplate allows a user to write a template using wiki markup and then rapidly create new pages based on that template.
- Copy PkTemplate.phpΔ to your pmwiki/cookbook directory
- Add the following line to local/config.php:
Creating a template
Create a page you'd like to use as a template. The page may contain non-template information; the template part starts with the markup:
Anything after that is part of the template.
Create fields that a user can populate with data using the markup
(:pktvar variablename A description of the variable
- pktvar = PK Template Variable
- don't use symbols in names
- limited markup for descriptions is ok, but nothing with
If you use the same variable more than once in the page, you may omit the description:
(:pktvar variablename:) (It will be ignored if you do give additional descriptions.)
Create blocks of text a user can populate with the Markup:
(:pkttext textblockname Description of what multi-line text goes here:)
Save the page and then you will be presented with a form to create new pages based on your template.
Filling out the form to create new pages
- New page name: New page names may contain spaces
- Creates a page Main.NewPageNamesMayContainSpaces
- New page name: May Use Group. Name For Convenience
- Creates MayUseGroup.NameForConvenience - ignores the "Group" field
- If "Add link to created page" is checked, a link to the newly created page will be added to the top of the template page
- This is useful to not lose pages.
- (Admin may change whether this is checked by default by specifying
What it looks like
If the template looks like this:
* [[Main.Enki-Addu | Enki-Addu]]
* [[Main.Micro | Micro]] (links to previously created pages)
(:pktvar catname The name of the cat:) likes to
(:pktvar catpasttime What does the cat like to do?:).
(:pktvar catpronoun What pronoun does the cat use?:)
is very soft.
(:pktvar catpronoun:) says:
(:pkttext meowmeow What the cat has to say to us ''humans'':)
A user might fill out the form like this:
And would create the page Main.LunarLander with contents:
Luna likes to Watch squirrels out the window. She is very soft.
Meow meow MROW 'MORWWW!'
- There is no real difference between
(:pkttext ...:). Both accept Markup and both may be multiline if a user is determined enough.
- Capitalization in the "template" markup is not important.
(:pktemplate:)both work. Currently, both
(:pktvar ...:) and (:PKTVAR ...:)work, but that is not guaranteed in the future: use lowercase "pktvar/pkttext" by preference.
(:include TemplatePages:)- the behavior is undefined. If you really need this, let me know, I might be able to provide an update.
- PkTemplate will not overwrite pages that already exist.
Admins may easily change a few behaviours:
$PkTemplate['addLinkByDefault']=false; // checkbox to add link to new pages is not checked SDV(
$HandleAuth['pkdotemplate'], 'admin'); // change permissions to admin(read/etc) include_once("
Change log / Release notes
If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".
- Markup text displayed at bottom of page now honors
$ROEPatterns, so user sees what they would see if they edited the page
- PkTemplate markup now runs "<_begin" so that (almost all) markup will actually be included in the template, including
- NewPageBoxPlus Adds customisable box plus button form for page creation
- FoxPageManagement creating new pages, new groups and copying pages with Fox forms
- PmForm Form processing engine for PmWiki