[pmwiki-users] New Hierarchical Groups Recipe...

The Editor editor at fast.st
Sat Feb 3 20:20:53 CST 2007


On 2/2/07, The Editor <editor at fast.st> wrote:
> On 2/2/07, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> > At the point of loading local/farmconfig.php or local/config.php,
> > PmWiki will have already initialized $pagename with the value of
> > any ?n= or PATH_INFO string.  However, PmWiki doesn't normalize
> > $pagename until ResolvePageName is called.
> >
> > So, it's just
> >
> >     $pagename = MySpecialResolveFunction($pagename);
>
> Ok, I got it.  Thanks!

I pulled together a function that allows you to optionally enter a
page name into the browser like Kingdom/Animal/Canine/Dog and it
automatically converts it to Kingdom-Animal-Canine.Dog.  Works
great...  It can also take the actual page name, with the hyphens and
dot, either way.

> > > >> >The problem with using a closing / or . at the end to indicate the
> > > >> >group is that many people won't see them there, or recognize that
> > > >> >they're a required part of the url.

This function works the same with or without a trailing slash.
(Basically ignores the last slash.

> > > >> Yes that crossed my mind too.  Do you have a suggestion?  I suppose if
> > > >> we just require them to manually enter Homepage, and get [[Group.]] to
> > > >> go to Homepage, that would solve the problem, wouldn't it?
> > > >
> > > >While it's one approach, I don't think it "solves the problem", since
> > > >the end result is to shift the work away from the computer and
> > > >onto people (and add some surprises/frustration in the process).

This change does require you to include the page name for the homepage
of each group.  But otherwise it works great. I'm looking forward to
Pm changing the core to allow admins to control the default settings
for group homepages.  This will be very helpful!

> Oh, and we'd also have to adjust the code for {$PageUrl} so that
> it converts hyphens-to-slashes when generating page urls.  But
> that one isn't nearly as difficult (and probably not worth worrying
> about until the other issues are decided first).

One last thing I would like to do is get the links to optionally be
formatted to go to the slash syntax, when a link is formed.  I have a
function that will take the contents of Group-Group.Name and change it
to Group/Group/Name (plus also a powerful shortcut for making links
relative to some point in the hierarchy that can be set in a config
file).  However, I'm not sure how to get this function called
properly.

I tried overwriting the $PageUrl page variable with this line but it
doesn't return anything for any of my links.  (As if group and name
are blank).

$FmtPV['$PageUrl'] = "'" . $ScriptUrl . "?n=" . hgURL("$group.$name") . "'";

If I change it to

$FmtPV['$PageUrl'] = "'" . $ScriptUrl . "?n=" . hgURL("$hggroup.$hgname") . "'";

It takes the current pagename and converts it from hyphens-dot to
slashes properly, but then every link on the page has that url.  So
the function works, but it needs to get the text of the link input
used for each instance of a link...

I also tried

$LinkPageExistsFmt = "<a class='wikilink' href='" . hgUrl($LinkUrl) .
"'>\$LinkText</a>";

but this doesn't seem to work either.

Can someone explain what I'm doing wrong...  I think this solution
will add some nice touches to the recipe, but it's a bit tricky and I
seem to need some help.

Cheers,
Dan



More information about the pmwiki-users mailing list