[pmwiki-devel] Creating a page text variable in a recipe
Hans
design5 at softflow.co.uk
Sun Sep 27 14:02:36 CDT 2009
Sunday, September 27, 2009, 7:10:57 PM, Simon wrote:
> I want a variable associated with a particular wiki page
> (cf {PageName$PageVariable} or {PageName$:PageTextVariable}
> that is set by the recipe and saved as part of the page contents.
in your function you need something like this:
//first get the page text content
$page = RetrieveAuthPage($pagename, 'edit', true);
if (!$page) Abort("?cannot edit $pagename");
$newpage = $page;
$text = $page['text'];
//do something to $text
//$key is name of PTV, $val is PTV value
//adding a PTV:
$text .= "\n(:$key: $val:)";
//saving the page with the modified $text
$newpage['text'] = $text;
UpdatePage($pagename, $page, $newpage);
//back to view the page
//redirect is good since we updated or added a PTV
//and want to see the change immidiately
Redirect($pagename);
//end of function
//or alternatively
// HandleDispatch($pagename,'browse');
// exit;
//end of function
Hans
More information about the pmwiki-devel
mailing list