PageRename
<< | Cookbook-V1 | >>
Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.
Goal
Give authors a way to change the name of a page.
Solution
Provide a rename action that makes a copy of the current page with a new name and redirects links from the old page to the new page. Existing references to the old name continue to work -- they just get redirected.
Files
Installation
Put rename.php in the local/ directory and add the following line to local/local.php:
include_once("local/rename.php");
Configuration
On a page that you want to rename, add ?action=rename to the url in the address box and press Return.
This takes you to a new view of the page that prompts you for a new name. Enter the new name and press Rename.
The script applies title case to the string you entered, turns any spaces into the space replace character, checks to see whether the new name is a valid title and that it doesn't already exist.
If all is well, you will see the new page name, with a redirected from ... message. Depending on how you have configured PmWiki/PmWiki, you may not see the redirected message.
The script currently allows you to change the title only, not the group.
See Also
Development.PageRename.
History
17 November 2003: released
Comments, Bugs
In a concatenation $WikiLibDirs
= array("wiki.d","wikibak.d","wikilib.d") a rename of a member which is in wikibak.d and not in wiki.d fails.
The redirect is correct, but the link is wrong, because the member couldn't be copied.
Patrick Ogay 23-Dec-2003
here the fix: loop through concatention, use oldpagefile
##----- foreach ($WikiLibDirs
as $dir) { $fp = @fopen("$dir/$oldpagefile","r"); /* not $pagefile! */ /* TestLog("\n dir: $dir/$pagefile -$fp-"); */ if ($fp) break; } if ($fp) { /* TestLog("\n $dir/$oldpagefile |$WikiDir
/$newpagefile"); */ if (!copy("$dir/$oldpagefile","$WikiDir
/$newpagefile")) { Abort("copy failed: $dir/$oldpagefile to$WikiDir
/$newpagefile") ;} } ##------
Patrick Ogay 26-Dec-2003
Contributors
- John Rankin (with thanks to the various contributors to the Development.PageRename page)
pmwiki-2.3.38 -- Last modified by {{}}?