Cookbook /
IncludeAble
Summary: How to include the current revision of a pmwiki page in another php page
Version:
Prerequisites: Last tested on PmWiki version: 2.0.6
Status:
Maintainer: Wesley Tanaka
Categories: Includes
Discussion: IncludeAble-Talk
Question
How do you include the current revision of a pmwiki page in another php page?
Answer
Let's say I want to include the current content of a pmwiki page in a php page called viewplace.php
1) Patch pmwiki.php in one place, namely:
changing the exit; on line 279 (version 2.0.6) to return;
See PITS.00548 fixed in pmwiki v 2.0.12!
2) Add this php code to viewplace.php:
<?php
$_REQUEST['pagename'] = 'pmwiki page';
$cwd = getcwd();
chdir('wiki');
include 'pmwiki.php';
chdir($cwd);
?>
3) To your config.php, add something like:
if (strpos($_SERVER['REQUEST_URI'], 'viewplace') !== FALSE
|| strpos($_SERVER['REQUEST_URI'], 'handleplacecomment') !== FALSE)
{
// Switch skin. This has to go first because stdconfig loads // scripts/skins which loads the skin. if (strpos($_SERVER['REQUEST_URI'], 'viewplace') !== FALSE)$Skin
= 'embed'; else if (strpos($_SERVER['REQUEST_URI'], 'handleplacecomment') !== FALSE)$Skin
= 'blank'; // process stdconfig. This has to go before clearing the // HTTPHeaders because some headers are set from stdconfig itself. include_once("$FarmD
/scripts/stdconfig.php"); // Disable stdconfig so that it doesn't get processed again.$EnableStdConfig
= FALSE; // stdconfig adds some stuff to that specified in the template file // (<div id='wikitext'> </div> and some blank lines), even though // our template is completely blank, so we try even harder to clear // out the template format. if (strpos($_SERVER['REQUEST_URI'], 'handleplacecomment') !== FALSE) { $TmplFmt=array(); } // Disable headers, since some output may have already been created // before pmwiki was included. $HTTPHeaders = array(); // Disable automated redirect for the same reason.$EnableFixedUrlRedirect
= FALSE; // Disable links, because they link back to the wiki URIs, which // may be confusing. This function could be rewritten to rewrite // the links to other pages instead, if that made sense. function Nothing($pagename
,$imap,$path,$title,$txt,$fmt=NULL) { return $txt; } $LinkFunctions = array('<:page>' => 'Nothing');$InterMapFiles
= array(); // Don't display any text if the pmwiki page is blank or doesn't exist. // Again, the default text might be confusing.$DefaultPageTextFmt
= '';
}
This code needs to be added after any other HTTPHeaders or Skin assignments in config.php.
4) Create an 'embed' skin with:
<!--PageText-->
in it.
Notes
Releases
See Also
Contributors
Comments
See discussion at IncludeAble-Talk