[Pmwiki-users] Why heirarchy?

John Rankin john.rankin
Thu Oct 21 14:40:40 CDT 2004


On Thursday, 21 October 2004 7:28 AM, Patrick R. Michaud <pmichaud at pobox.com> wrote:
>[resending to cc: pmwiki-users]
>
>On Wed, Oct 20, 2004 at 10:30:06AM -0700, Fred Chittenden wrote:
>> A simple league template with
>> nestable hierarchy would seem to be quite easy:
>
>Except that you seem to be focusing on the names while ignoring my points 
>about the issues with relative links.  To wit, let's look at the 
>template you just provided, and we'll assume it's in
>RecSoccer.BoysU8.HomePage:
>
>> --------------------
>> Rec Soccer Boys <Age>
>> [[LeagueSchedule]]
>> [[LeagueStandings]]
>> Teams -- 
>> [[TeamA]]
>> [[TeamB]]
>> [[TeamC]]
>
>Okay, these are all links to siblings of RecSoccer.BoysU8.HomePage, 
>so this creates links to pages 
>   RecSoccer.BoysU8.LeagueSchedule
>   RecSoccer.BoysU8.LeagueStandings
>   RecSoccer.BoysU8.TeamA
>   RecSoccer.BoysU8.TeamB
>   RecSoccer.BoysU8.TeamC
>
>No problem so far.

Leaving aside the bigger issues around page hierarchies, I wonder
if a small extension to PmWiki 2 would solve the immediate *practical* 
problem. In part anyway. 'Sub-page markup.'

Suppose I'm on the page RecSoccerBoysU8.TeamA and I write [[_Schedule]]
(using the _ as an illustration) or [[_TeamNews]].

PmWiki interprets this as a reference to [[RecSoccerBoysU8.TeamA_Schedule]]

Suppose I'm on the page [[RecSoccerBoysU8.TeamA_Schedule]] and I want to
get to [[RecSoccerBoysU8.TeamA_TeamNews]] -- I write [[_TeamNews]].

In other words, the algorithm is 'if the current page contains an underscore,
treat this as a sibling reference, otherwise treat it as a child reference.
This only works for one level of sub-page.

People will inevitable write [[Schedule]] by mistake and end up on
[[RecSoccerBoysU8.Schedule]]. On that page, we put:

    (:searchresults group=RecSoccerBoysU8 _Schedule :)

This lists TeamA_Schedule, TeamB_Schedule and so on.
(I may have the syntax wrong, but you get the idea) 

You may want a template that looks like this

RecSoccerBoysU8 / TeamA
Schedule

instead of the normal

RecSoccerBoysU8 /
TeamA_Schedule

The following should work (give or take php syntax errors):

Markup('[[_','<links','/\[\[(_.*?)\]\]/e',
   "'[['.MakeSubPage(\$pagename,PSS('$1').' | '.PSS('$1').']]'");

function MakeSubPage($pagename,$subpage) {
  $parent = preg_replace('/_.*$/','',FmtPageName('$Name',$pagename));
  return "$parent$subpage";
}

Will this help solve the immediate problem?
-- 
JR
--
John Rankin





More information about the pmwiki-users mailing list