[Pmwiki-users] how to implement multi-level groups

Robert P. J. Day rpjday
Mon Oct 18 14:40:24 CDT 2004


  i think i have a way to implement multi-level groups that's not
unspeakably offensive and, most importantly, doesn't require *any*
changes if you stick with single-level groups.

  consider an initial top-level group, Soundcards, with a number of
pages referring to specific soundcards, such as the ExtremePain card
among others (or EP for short).  so Group=SoundCards, Page=EP, and i
can refer to this page in two ways:

  [[EP]] 		from within the group
  [[SoundCards/EP]] 	from a different group

that's already supported, so nothing changes.  i can even, if i want,
get pedantic and allow

  [[/SoundCards/EP]]

which should be perfectly acceptable as an absolute pathname.  so far,
so good, nothing too exciting.

  now, i decide that i really want to create additional group levels
that represent the manufacturer above this {IBM,Acme}, and on top of
*that*, i have a categorization for hardware (HW) or software (SW).
so, in essense, i have the possibilities:

  {SW,HW}/{IBM,Acme}/{SoundCards,VideoCards,HardDrives}/{EP, ...}

you get the idea.  i now have a 4-level wiki, where each page has a
3-element group name.  now, from any page, how do i refer to some
other page in the wiki?

  say i'm at the page for IBM's "EP" sound card: HW.IBM.SoundCards.EP.
how do i refer to another page?  well, if it's just another IBM sound
card, just like i do now:  [[SP]] (for the SeriousPain card).  so
nothing there changes and i'm fine.

  if however, i want to refer to someone else's soundcard, it's as
simple as (for example):

  [[Acme/Soundcards/AP]]  (AP = agonizing pain)

how did i resolve that?  easy.  i take the first level group name,
"Acme", and start working my way up the groups from my current
location until i hit a match.  i assume that's what i was looking for
and resolve relative to that.  piece of cake.  naturally, there is the
possibility for ambiguity, but this resolution scheme should work 95%
of the time correctly and, where it fails, it's just because you were
just trying to push it too hard.

  what benefit does this scheme have?  well, it clearly doesn't affect
resolving within the same group -- that doesn't change.  if i'm in the
SoundCards group, i could refer to another soundcard as *either* of

  [[EP]]
  [[SoundCards/EP]]

since the resolution scheme would resolve to the same page in either
case, and it wouldn't matter if the SoundCards group was moved
elsewhere -- it would still work.

  what if i wanted to refer to someone else's soundcard from with
IBM's cards?  easy:

  [[Acme/SoundCards/AP]]

again, i start at my current location and work my way up the hierarchy
until i match "Acme", at which point i assume that's what i was
looking for, and i head down from there.

  the advantage of this scheme is:

  1) no page needs to know about the *entire* wiki structure, it only
really needs to know about its own local vicinity to find the pages it
wants.

  2) large subtrees can be moved around without breaking anything,
*unless* you try to get too fancy and try to refer to pages way the
hell somewhere else in the wiki.  but if that's the case, you probably
deserve what you get. :-)

  and as a final advantage, you can always override the default
resolution process with an absolute pathname, like:

  [[/HW/Acme/Soundcards/AP]]


in effect, what this resolution scheme doing is *somewhat* analogous
to using "../../.." in a file pathname.  however, rather than being
explicit with your use of "..", all you want is for the resolution
process to work its way up the tree structure to ancestors until *it*
decides it's hit a match.  and, for the most part, i think this will
work just fine.

  thoughts?

rday



More information about the pmwiki-users mailing list