[pmwiki-devel] Creating a page text variable in a recipe
Simon
nzskiwi at gmail.com
Sun Sep 27 23:43:30 CDT 2009
Thanks very much Hans and Peter.I'll work in these solutions as soon as I
can.
Is there a way I can test and only do this if the page is being saved
(rather than browsed, previewed, etc)
Simon
2009/9/28 Hans <design5 at softflow.co.uk>
> 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
>
>
--
____
http://kiwiwiki.co.nz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.pmichaud.com/pipermail/pmwiki-devel/attachments/20090928/1d736813/attachment-0001.html
More information about the pmwiki-devel
mailing list