[Pmwiki-users] Developer Question
Patrick R. Michaud
pmichaud
Sun Mar 21 23:34:15 CST 2004
On Mon, Mar 22, 2004 at 11:31:51AM -0800, Steven Leite wrote:
>
> I'm writing an add-on, and I want to pull information from a data
> file. If I just include the following line of text in my .php file:
> $filename = "datafile.txt";
> $file_contents = file($filename);
> That solves my problem, but I want to do more. I want the data files
> to be a WikiPage.
>
> Q: How can I extract the contents of a WikiPage and send it to my
> script?
If you just want the markup text of the WikiPage and you're running
from pmwiki.php, then the easy way is:
$page = ReadPage('Group.WikiPage');
$text = $page['text'];
Otherwise, there are other options for reading the file:
1. You could duplicate the ReadPage script into your own PHP script.
2. You can use PmWiki's ?action=source action to retrieve the markup text
3. You can use the following Unix shell command:
grep '^text=' wiki.d/Group.WikiPage | tr "\262" "\012"
4. You can do the equivalent of the Unix shell command in PHP:
$text_array = preg_grep('/^text=/',file('wiki.d/Group.WikiPage'));
$text = str_replace("\262","\n",$text_array[0]);
If you're wanting the rendered output of the page (i.e., after it's been
converted to HTML):
1. If you need the HTML from some script called by pmwiki.php, then
maybe I can fix PrintText() to return a string.
2. Alternately, you can make your own calls to PrintText() or PrintWikiPage()
and surround the calls with ob_start/ob_get_contents.
3. From outside of PHP, you can create a minimal skin template and then call
pmwiki.php to render the page using the minimal skin. I.e., create
a minskin.tmpl file that contains nothing but <!--PrintText-->, then
call PmWiki with that skin
(http://localhost/pmwiki.php/Main/HomePage?skin=minskin).
Hope this helps?
Pm
More information about the pmwiki-users
mailing list