[pmwiki-users] Pagelists, trails and categories: bug and fix.
Martin Fick
fick at fgm.com
Thu Nov 17 15:09:50 CST 2005
When using a cateogry in a trail such as:
page: MyGroup.FooTrail
* [[Foo.Bar]]
* [[Foo.MiliBar]]
* [[!Silly]]
...
and trying to do a paglist on it using:
(:pagelist trail=MyGroup.FooTrail:)
the category ends up getting listed as a page in the
MyGroup group, as MyGroup.Silly.
ANALYSIS:
The problem occurs in the trails.php ReadTrails() function
around here:
if (!preg_match("/^([#*:]+) \\s*
(\\[\\[([^|]*?)(\\|.*?)?\\]\\]($SuffixPattern)
| (($GroupPattern([\\/.]))?$WikiWordPattern))/x",$x,$match))
continue;
if (@$match[6]) {
if (!$LinkWikiWords) continue;
$tgt = MakePageName($trailname,$match[6]);
} else $tgt = MakePageName($trailname,$match[3]);
The $match[3] will get set to '!Silly' and then passed to
MakePageName() which returns the wrong answer:
MyGroup.Silly.
FIX:
I'm not sure if MakePageName() should be able to handle
this correctly, but one way to intercept it before it
even gets there is to add this line:
$match[3] = preg_replace("|^\!|", "Category.", $match[3]);
right before the line:
if (@$match[6]) {
With this patch, $match[3] will end up like
'Category.Silly', MakePageName() handles that properly.
WHY:
One might ask why one wants to do this? Well it allows
all the links and categories of a page to be summarized
nicely, particularly using either the PageListTemplates
or CompactPageList recipes. With the former recipe it
should be possible to even weed out the non category
links - someone previously asked for a way to get a list
of categories that a page belongs to.
Cheers,
-Martin
More information about the pmwiki-users
mailing list