[pmwiki-users] How to include wiki page into php variable?

Patrick R. Michaud pmichaud at pobox.com
Sat Apr 8 17:06:32 CDT 2006


On Sat, Apr 08, 2006 at 08:11:44PM +0100, Octocias wrote:
>    As a follow-up, I've tried to borrow code from the (:include:) markup and
>    I did:
> 
>    $out = PRR(IncludeText( 'Group.Pagename', ''));
> 
>    .. without success.
> 
>    Can you tell me if this is supposed to work or how to make it work?


If you just want to read the text of another page, it's:

    $page = ReadPage('Group.Pagename', READPAGE_CURRENT);
    $out = $page['text'];

The READPAGE_CURRENT says that you're just interested in the
most recent version of the page (so you can avoid reading the
history).  If you want the history read also, omit the READPAGE_CURRENT.

Note that this doesn't do any authorization checking for the page --
it reads it even if the current visitor isn't authorized to view
it.  To get the page only if the visitor has permission to see it,
then use:

    $page = RetrieveAuthPage('Group.Pagename', 'read', false, READPAGE_CURRENT);
    if (!$page) { ...can't read page... }
    $out = $page['text'];

Pm




More information about the pmwiki-users mailing list