[Pmwiki-users] wikitrails from pagelist

John Rankin john.rankin
Sun Nov 14 18:37:21 CST 2004

On Monday, 15 November 2004 1:14 PM, Val Sharp <val at valsharp.co.uk> wrote:
>I'm trying to find a way to derive wikitrails from a (:pagelist...:) 
>list on an index page.
>However, the ReadPage function called from the trails script is 
>returning the pagelist directive itself as the contents of the page, 
>rather than the list that the pagelist is intended to generate.
>So I thought of two ways of perhaps achieving what I want:
Something like this is definitely possible. And useful.

What about the following brute force method. 

3. make an extra trail markup, such as:


Have this return a MakeTrailStopC function, following the
Markup(...); style of MakeTrailStopA and MakeTrailStopB.

Let's recap the logic first.
To process trail markup, Pmwiki does the following:

- read TrailPage

- build a list of stops on the trail, using what it
finds on TrailPage

- traverse the list looking for the current page

- return links to the next and previous pages in the list

MakeTrailStopC needs a BuildTrail function that builds an array of
stops based on the contents of (:pagelist ... :) on TrailPage.
You'd call this where MakeTrailStopA calls ReadTrail. The only
difference beteen MakeTrailStopA and MakeTrailStopC is the 
latter calls BuildTrail instead of ReadTrail.

As you say, after BuildTrail reads the TrailPage, it needs to 
translate (:oagelist ... :) into an array of stops, instead of 
building the array from list items on the page. From memory, 
FmtPageList puts this into the FmtV['MatchList'] global variable.

So then you'd need to do something like

    global $FmtV;
    foreach($FmtV['MatchList'] as $t) { ... }

Have a look at where FmtPagelist puts its array of pagenames
for subsequent processing, as that's what you'll need to access.

Sorry this is a bit vague; I *know* it's possible, because I
did something similar to build a pick list of group names.

With luck it will give you some ideas.

>But I'm having trouble figuring out the required parameters for 
>function FmtPageList ... for example, in the second case I was trying 
>something like
>function ReadTrail($pagename,$trailname) {
>   global
>if (substr($trailname,0,9) == ":pagelist") {
>   $trailpage = preg_replace('/\\:pagelist\\s*(.*)\\:/e',
>   "FmtPageList('\$MatchList',\$pagename,array('o'=>PSS('$1 

in the suggested BuildTrail function, this becomes something like

if preg_match('/\\(:pagelist\\s*(.*?):\\)/',$trailpage['text'],$match) {
   $t = FmtPageList('$MatchList',$trailname,array('o'=>$match[1]));
   now process the list of stops that FmtPageList just built...

I know that's not quite right, but hope it's helpful. I'll have a look
at Patrick's code later, so if your response is "this isn't working"
I can try to be a bit more useful.

John Rankin

More information about the pmwiki-users mailing list