MasteringPmWikiPages

Summary: Consolidating documentation on making & breaking PmWiki pages for recipe authors.
Version: 2014-02-07
Prerequisites: none
Status: documentation
Maintainer: XES
License: CC0
Categories: PmWiki Developer
Users: (view? / edit)

How do I find the correct documentation to create recipes that manipulate PmWiki pages?

Description

This page is to help PmWiki Developers to get a better idea of the workflow and hooks available to deal with PmWiki pages, and to consolidate documentation about the PmWiki page creation, updating and deleting process.

Philosophy

If you're wondering why PmWiki doesn't use a database, or what the advantages are of using a flat-file system, please see FlatFileAdvantages.

Dealing directly with Page files on the system

See PageFileFormat to familiarize yourself with the raw text file format and for information on reading & writing to raw pmwiki/wiki.d/ PmWiki text files. These files correspond to the pages on the wiki, and by default are found at pmwiki/wiki.d/GroupName.PageName. There are also pages for documentation and settings files found in pmwiki/wikilib.d/ which are overwritten upon upgrade. If a file for a page is not found in pmwiki/wiki.d/, then pmwiki/wikilib.d/ is searched for the file. All changed files should be written to pmwiki/wiki.d/ to avoid being overwritten. If you want to add another PageStore to the system so that you do not overwrite the wiki.d files (just in case), see Cookbook.PerGroupSubDirectories for an example of changing the PageStore.

Also, there's a useful list of what information is stored in the wikipage at PageFileFormat. The extra data can either be accessed via PmWiki's PHP Variables or in wiki markup as PageVariables.

There are some shell scripts available to help manipulate PmWiki files on the system at Cookbook.AdminByShell.

Raw Wiki Markup

To retrieve raw wiki markup from the page files, as if you're going to edit the page in a web browser:

$page = RetrieveAuthPage(...); // check docs or php source
$text = $page['text']; // plain text
$EditText = PHSC($text, ENT_NOQUOTES); // htmlspecialchars inside e_textarea

Alternatively you might just need http://yourwiki.com/pmwiki/pmwiki.php?n=YourGroup.YourPage&action=source. Keep in mind, grabbing source from the browser without a password may be (and probably should be) blocked by your wiki administrator. (see PmWiki.Security)

Saving or Updating Raw Wiki Markup via PmWiki

For recipe authors who need to borrow PmWiki's internal page creation/updating system, see documentation on using PmWiki's UpdatePage function. When using user-inputted text to determine the $pagename of a new page, use FmtPageName() (see FmtPageName); it will strip out whitespace and invalid characters and render the text in CamelCase, and apply it to the group of the $pagename (a reference page) passed to the FmtPageName() function.

Deleting PmWiki Pages

Any page sent to the UpdatePage() with only the $page['text'] = 'delete'; will be deleted from the wiki. Deleted pages are renamed in the wiki.d pagestore by default and excluded from all wiki-side transactions including pagelists, etc. Without adding functionality to PmWiki they can only be restored by directly renaming the files on the server i.e. by using FTP, SSH, etc. to rename wiki.d/Main.Products-Draft,del-1386894538 back to wiki.d/Main.Products. There is more information on deleting pages and changing the word used to delete pages at PmWiki.Deleting Pages.


Change log / Release notes

  • 2014-02-07 First release.

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".

See also

PmWiki Developer

Contributors

Comments

See discussion at MasteringPmWikiPages-Talk?

User notes? : 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.