[Pmwiki-users] Developer Question
Steven Leite
steven_leite
Mon Mar 22 00:05:40 CST 2004
Patrick, that helped TREMENDOUSLY!
It will be a shame for this information to go to waste. I know there's a
Developer section already on PmWiki, but this information doesn't seem to
fit there. Maybe we can add it to a DeveloperFAQ or something. It's
valuable stuff.
Thanks again. Also thanks to to Greg who also repsponded!
Steven Leite
----- Original Message -----
From: "Patrick R. Michaud" <pmichaud at pobox.com>
To: "Steven Leite" <steven_leite at kitimat.net>
Cc: <pmwiki-users at pmichaud.com>
Sent: Sunday, March 21, 2004 10:34 PM
Subject: Re: [Pmwiki-users] Developer Question
> 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