[pmwiki-devel] LinkUrl / LinkTxt question

The Editor editor at fast.st
Tue Feb 6 11:12:08 CST 2007


On 2/6/07, Patrick R. Michaud <pmichaud at pobox.com> wrote:
> On Tue, Feb 06, 2007 at 08:45:12AM -0500, The Editor wrote:
> > Just a quick question (second post)...
> >
> > Is there any way you can reset how the link text is displayed in a wiki page?
> >
> > That is, I have the Hg recipe converting the pageurl as desired, and
> > have it resolving properly as well (almost, see below).  But in two
> > instances the displayed link text does not match the actual link.
> > Specifically:
> >
> > 1.  [[Group/Group]] links to Group/HomePage but displays as
> > Group/Group (ie Group).  Not all bad but could be misleading.
> > Group.HomePage displaying as Group.Group is a bit more problematic.
>
> You want [[Group/Group]] to link to Group.HomePage?  Why would
> we want that?  PmWiki's philosophy is to honor what the author
> writes and not attempt to second-guess it.

Actually what I want is for [[Group.]] to link to Group.Home or
whatever I set it to. Until there's a way built into PmWiki to set the
$DefaultName for pages that don't exist, I came up with a workound.
Basically, I have a line in the function that defines PageUrl that
says, if name==group then name=$DefaultName.  It does what I want,
except 1) it overrides a link like test.test and 2) when triggered,
the linktxt doesn't match the linkurl.  It's a tradeoff I'm willing to
make to avoid pages like Test-Main-One-Alpha.Test-Main-One-Alpha.  I
much prefer Test/Main/One/Alpha/Home.

If I can reset the linktxt somehow, that would solve problem 2 at
least.  Of course, if you could modify core to allow default home
pages to be set for groups, that would solve problems one and two for
me and greatly simplify my project. Until then, my solution is the
best hack I can manage until then.  So I can start using Hg as I want
to.

> > 2.  [[Group.]] links to Group/HomePage but displays as "Group.".
> > Again, not terrible but the dot is easy to miss.
>
> PmWiki's philosophy on link text has generally been that whatever
> is inside the double brackets is what should be displayed as the
> link text.   The exceptions are that parens and slashes are
> convenient shortcuts for suppressing part of the link text.

Default PmWiki has the same problem Hg has in the instance of
[[Test.]].  Whether considered a bug or a feature, the linktext is
"Test." while the linkurl is "Test.Test". My problem is similar, only
a bit bigger because [[Test.Test]] has linktxt Test.Test but linkurl
Test.HomePage, which is less acceptable.

> > One option for problem one is to override the LinkPageExistsFmt.  Can
> > this be set to a function that is passed PageUrl and LinkText and uses
> > the first if the second is not set?
>
> This is all handled by the MakeLink() function.  It says that
> if there is no explicit link text provided, it uses the text of
> the target after removing any parens.  It's part of PmWiki's
> standard that "whatever is written in double brackets is
> what gets displayed as the link text."
>
> It would probably be possible to override this standard, but
> it would have to be done with replacement versions of the
> MakeLink() and/or LinkPage() functions.

I've looked at these function and they are over my head... No clue.

Is there a reason the linktxt cannot be set to the pageurl instead of
the linkurl (when no title is supplied)?  That would solve the
problem, and hopefully not break anything else.  Of course, those
functions are pretty involved Pm, so I can't tell...  (I'd be willing
to test a core hack if you can suggest it).

Or is it a big project to tweak PmWiki to enable the defaultname
setting to be used when pages do not exist?  I prefer the hack
suggested above better--as it also makes other options possible, but
this would be an acceptable alternative.

Or a last option, is it possible to redefine LinkPageExistsFmt by a
function that is passed linkurl, linktxt and pageurl, and rewrite the
output in the formula using conditionals, etc.  Is that possible?

I hate to have to give up...  There's got to be a way...

Finally any thought on this real bug:  I just noted that while things
work fine with Group.Name, if I use the Group/Name notation in the
link, Hg seems to draw a blank...  No clue what the problem is.  You
can see it at:

http://www.fast.st/hgtest/index.php?n=Test/Prefix/Home.

To edit, double click on page.  I'm kind of stumped.

Cheers,
Dan



More information about the pmwiki-devel mailing list