IncludeAble-Talk

Summary: Talk page for IncludeAble.
Maintainer: Wesley Tanaka
Users: (View? / Edit)

This space is for User-contributed commentary and notes. Please include your name and a date along with your comment.

Comments

It's possible to add items to a pmwiki page without going to a pm wiki page by doing something like:

if ($datathere) {

   // Necessary because if the pmwiki page exists, there's no way to make
   // pmwiki.php not output anything.   HandleBrowse has a hardcoded
   // $PageText in HandleBrowseFmt.
   $_REQUEST['pagename'] = 'Some.Pmwiki.Page.Or.Other.Which.Does.Not.Exist';
   $cwd = getcwd();
   chdir('../wiki');
   include 'pmwiki.php';
   $_REQUEST['pagename'] = 'PmwikiPage.To.Change';
   $oldpage = RetrieveAuthPage($_REQUEST['pagename'], 'read');
   $newpage = $oldpage;
   $newpage['text'] .= "\n!!!" . 'comments go here';
   PostPage($_REQUEST['pagename'], $oldpage, $newpage);
   chdir($cwd);
   header('Location: [(approve links)
  edit
  diff]');

} else {

   header("Location: [(approve links)
  edit
  diff]");

}

By pointing _REQUEST['pagename'] to a pmwiki page that doesn't exist, and by applying the above patches as well, pmwiki.php doesn't generate any output, which allows you to set headers (e.g. redirect) after the pmwiki page has been updated. Be careful, because pmwiki appears to clear variables you may have set before it was included. I got around this by storing things in $_REQUEST.


I'm also interested in plugging in the authentication mechanism for the rest of my website so that comments by logged in users will be treated and logged differently than comments from anonymous guests. I saw some reference to that on another page, but nothing specific yet.


This seems like it could be used as a recipe to create includes which execute with the 'context' of the included page. This would mean that vars like {$Name} and {$Group} would get replaced with the values of the included page instead of the including page. - Martin Fick November 07, 2005, at 04:48 PM

Talk page for the IncludeAble recipe (users?).