Recent Changes - Search:




Summary: Adds customisable box plus button form for page creation
Version: 2014-02-21
Prerequisites: PmWiki 2.2.56 (compatible with PHP 5.5)
Status: Stable
Maintainer: HansB
Users: +5 (View / Edit)
Categories: Forms CMS PHP55


How can I provide a form or box to allow users to create new pages?


As with the original, this alternative script adds markup that places a simple box with a button. Filling in the box with a page name and pressing the button will create the page. Parameters (see below) allow for styling the box, button, setting page name, and page-creation behavior.

The newpageboxplus.phpΔ script provides a (:newpagebox:) markup which displays a simple box for creating pages:



To install, download newpageboxplus.phpΔ, copy into the cookbook folder, and add the following to config.php:


This script can be used as an alternative to NewPageBox and should be installed instead of newpagebox.php.

This script adds additional functionality:

  • The button can be placed either to the right or the left of the input box.
  • The input box can have an initial text displayed inside the box.
  • This can be made to disappear as soon as the box is clicked to enter the new page name, or left as an initial value for a second part of the page name to be entered.
  • The input box and button have additional class stylehooks "inputbox" and "inputbutton" which help integrated styling in a skin (used by Gemini Skin, FixFlow Skin, Triad Skin for instance), i.e. you can use a generic class for both searchbox and newpagebox and other form elements for instance.


Usage is the same as original script, by adding this markup to any wiki page:



Possible parameters to use inside the markup:

  • base=Group.PageName -- create page in the same group as Group.PageName (PageName does not need to exist).
  • template=Group.PageTemplateName -- use Group.PageTemplateName as template for new page.
  • value="Create New Page" -- label or value for the inside of the field, which disappears when clicking the box. Default is empty: "".
  • prefix=prefixtext -- prefix will be added in front of name.
  • suffix=suffixtext -- suffix will be added behind name.
  • size=number -- size of input box, default is 30.
  • label="Button Label" -- label for the button, default "Create a new page called:".
  • button=position -- use "left" or "right" to position button (default is "left").
  • focus=true -- adds onfocus and onblur javascript which will make any initial value disappear when clicking on the box. Default is "".
  • save=true or save=1 -- will save the new page directly (without opening it in edit mode), adding any content set with the template option. Default is "". This option is disabled by default, but available for users logged on with 'edit' level. To make it generally available for all users set as local configuration $EnableAutoSave = 1;

Optional config settings

This is an array of protected groups, for which creation of new pages is prohibited. Default protected groups are 'SiteAdmin' and 'Site'.
$NewPageProtectedGroups[] = 'SpecialGroup';
adds 'SpecialGroup' to array of protected groups.
$NewPageBaseGroup = 'Main';
(example) all new pages will be created in 'Main' group (regardless of any base= parameter setting).

New pages will be created in group "Test":

(:newpagebox base=Test.HomePage:)

(:newpagebox base=Test.HomePage:)

Small box with left "Go" button for use in sidebar:

(:newpagebox value="Create New Page" focus=true label=Go button=right size=16:)

(:newpagebox value="Create New Page" focus=true label=Go button=right size=16:)

Update History

  • 2014-02-21: updated markup definition for PHP 5.5 compatibility.
  • 2009-01-29: fixed bug in $NewPageBaseGroup.
  • 2009-01-20: added $NewPageProtectedGroups array and $NewPageBaseGroup variable.
  • 2008-04-27: Fixed save= option so only save=1 or save=true will result in a page save without opening the edit window.
  • 2007-05-02: Changed buggy action to PageUrl, this time properly!
  • 2007-04-17: Changed $PageUrl to $ScriptUrl in form.
  • 2007-01-25: Small optimisation tweak. Removed size default.
  • 2007-01-24a: Optimised code so HTML output is minimised. Hidden fields are only added when needed by the markup.
  • 2007-01-24: Added prefix and suffix optional parameters.
  • 2006-11-26: Added $EnableAutoSave, default false. save=true option is now only available if this variable is set to true or if user is logged on with 'edit' authorisation.
  • 2006-10-28: Added $RecipeInfo
  • 2006-08-05: Added code to strip periods from names, if a base= parameter is specified.
  • 2006-04-28: Added call to SaveAttributes when save=true, which saves link targets.
  • 2006-04-15: Added ctime (page creation time) when new page gets auto saved.
  • 2006-04-10a: Rewritten posting code so new page will appear in RecentChanges, even with save-true option.
  • 2006-04-10: Added Author name when new page gets auto saved.
  • 23 March 06: Changed onfocus/onblur behaviour: Added checking the textbox is still equal to the "value" parameter to stop inadvertant opening of page. Entering a value, leaving the box and returning will have the value still intact and not removed by the second onfocus.
  • 23 March 06: Fixed bug which would open an existing page of form Group.Group if Group was entered and a base group specified. Now the new page will be Base.Group.
  • 20 March 06: Fixed Redirect to new page when save=true.
  • 17 March 06: Fixed bug which allowed overwriting of an existing page by using option save=true. Now it is first checked if the new page exists already, and if it does, it wil open in normal edit mode, and not automatically save a page template as new page content.
  • 27 Feb 06: Added "save" option, which when set to save=true will save the new page without opening it for editing. Combined with the template option new pages with content can be created easily. I use it to create new blog archive and category pages.
  • 4 Jan 06: First release as fourth version of newpagebox.
  • This recipe was last tested on PmWiki version: 2.1.beta17
  • This recipe requires at least PmWiki version: 2


See Also


See discussion at NewPageBoxPlus-Talk

User notes +5: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on March 15, 2014, at 02:22 PM