Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

AddPageForm

Summary: How to add new pages without creating a link first
Version:
Prerequisites: Last tested on PmWiki version: 2.beta26
Status:
Maintainer:
Categories: Forms, Links

Question

How can we add pages without creating broken links first?

Answer

The question mark links which appear on some pages and point to non-existing other pages are not broken links, they are invitations to create a new page. They are also a good way for people to check that they spelled properly the page names.

However, to answer the question, there are two ways: default and automatic.

Wiki default

Just edit the URI in the Address field in the browser to place the name of the new page (or group) in the right position, e.g.:

     http://<domain.ext>/<path-to-wiki>/<groupname>/<pagename>

Automatic, using a form

However, if you don't want to let your users get their hands dirty and possibly mess up the URI, add the following to the top of your local/config.php:

 
if ($_GET['createfrom']!="") {
   $pagename=MakePageName($_GET['createfrom'],$pagename);
}
$CreatePageForm='<form action="'.$ScriptUrl.'">
  <input type="text" name="n" value="NameOfThePage" />
  <input type="hidden" name="action" value="edit" />
  <input type="hidden" name="createfrom" value="'.$pagename.'" />
  <input type="submit" name="submit" value="Create" />
</form>';
Markup('createpage','directives','/\(\:createpage\:\)/e',
      "Keep('$CreatePageForm')");

Then you can put the new markup (:createpage:) in a skin, template, included page or in pages where you want people to see the form: one text field followed by a Create button.

Typing the name of a new page in the text field and pressing Create opens the edit page on the new page.

Notes and Comments

Maybe some js could be added to the Change button to make sure empty pages are not requested...

Pm took this to the next level at NewPageBox

Should this go in the Superseded section? - Martin Fick

See Also

Contributors

  • Nils Knappmeier
  • Radu (put this page up and made some comments :)

See also

NewPageBox

NewPageForm

Notes and Comments

I´ve a problem with this function: By using the create-button, the link in the Group left, where the page is created (in all cookbook-versions..). It's possible to extend the create-markup, that on the site where the user pushes the createpage-button, a link will set to the new page? Anyone else the markup doesn't appear well, when in wiki the link () so or so must placed. - Kai

Edit - History - Print - Recent Changes - Search
Page last modified on March 27, 2007, at 10:06 AM