[pmwiki-users] PmWiki 2.2-beta12 - UpdatePage() released
The Editor
editor at fast.st
Wed Oct 4 11:47:22 CDT 2006
> Crisses wrote:
> > Module maintainers and programmers should be very happy to know that PM
> > has released -beta12 yesterday with UpdatePage() capabilities.
> >
> > This function allows you to update pages in the wiki with full and
> > proper updating of the wiki -- RecentChanges, Diffs, or auto-adding
> > Categories (see other changes in the Release Notes) for example.
> >
> > Usage:
> >
> > UpdatePage($pagename, $oldpage, $newpage);
> >
> > In this case $oldpage is the array format pulled from
> > ReadPage($pagename);
> > $newpage should be a similar array. Note that $newpage['text'] would be
> > the new text to be the full body of the page.
> > A diff will be calculated between $oldpage['text'] and $newpage['text']
> >
> > Example use:
> > $pagename = "Group.PageName";
> > $text ="I want to completely change the page body and replace it with
> > this text.";
> > XESReplacePage($pagename,$text);
> > function XESReplacePage($pagename, $text){
> > $oldpage = ReadPage($pagename);
> > $newpage = $oldpage;
> > $newpage['text'] = $text;
> > UpdatePage($pagename, $oldpage, $newpage);
> > }
> >
Uh, help? I just downloaded the latest beta (12) and tried rewriting
my setpage function which is the only place doing file saves. And I'm
getting this message:
PmWiki can't process your request
Cannot write page to (wiki.d/)...changes not saved
We are sorry for any inconvenience.
Here's the function written mostly with cut and pastes from Crisses
input. Any thoughts anyone?
function SetPage() {
global $WorkDir, $data, $log, $_POST, $DataKey;
$d = $DataKey.$_POST[datapage];
$oldpage = ReadPage($d);
$newpage = $oldpage;
$newpage['text'] = "(:comment data:) \n\n$data(:comment data:)
\n\n[[#Log]] \n\n$log(:comment data:) \n\n";
UpdatePage($pagename, $oldpage, $newpage);
return;
}
Any help that anyone could give would be appreciated. BTW, will this
work if a page is not yet created also? Or will I have to do
conditionals and have two methods for saving? In this case the page
does exist.
Cheers
Caveman
More information about the pmwiki-users
mailing list