[pmwiki-users] Re: data from wiki page rather than file
Patrick R. Michaud
pmichaud at pobox.com
Thu May 5 08:01:02 CDT 2005
On Thu, May 05, 2005 at 01:58:02PM +0200, chr at home.se wrote:
> On Wed, 4 May 2005, Patrick R. Michaud wrote:
> > On Wed, May 04, 2005 at 05:55:01PM -0700, Carl Boe wrote:
> > > In general, is there an accepted way to have markup for a page depend upon
> > > and manipulate raw content in another page, not just include it?
> > Yes, this can happen -- in general one uses the ReadPage() function
> > to get at the wiki page data (or RetrieveAuthFunction() if authorization
> > issues need to be handled).
>
> Maybe it'd be convenient for cookbook authors if there was a function that
> they could call to extract text data from wiki pages. Maybe the function
> could be invoked like this:
> $textArray = GetDataFromPage($page, $OptStartTag, $OptEndTag);
> where if there are no optional tags, the entire page is returned as a
> string in $textArray.
Perhaps, or maybe we just publish the code idioms:
$apage = ReadPage('Group.SomeOtherPage', READPAGE_CURRENT);
$atext = $apage['text'];
# full text is in $atext
or
$apage = ReadPage('Group.SomeOtherPage', READPAGE_CURRENT);
preg_match_all(
'/\\(:mytag:\\)(.*?)\\(:mytagend:\\)/i',
$apage['text'],
$match);
$textArray = $match[1];
# extracted components are in $textArray[1]
foreach ($textArray[1] as $x) { echo $x, "\n"; }
I think there could be too many variations in the formats for
(:mytag:) and (:mytagend:) to be usefully encoded as simple
variables. For example, one might also need to capture any
option arguments in (:mytag:), or one might want to be able to
capture things like:
(:mytag:) ... (:mytag:) ... (:mytagend:)
So I think maybe it's better to just give "here's the base
code fragment" and let recipe writers customize it to suit.
Pm
More information about the pmwiki-users
mailing list