[pmwiki-users] categories in pagelist
Patrick R. Michaud
pmichaud at pobox.com
Mon Apr 2 12:29:23 CDT 2007
On Mon, Apr 02, 2007 at 04:35:38PM +0000, J. Meijer wrote:
> On 4/1/07, Petko Yotov <5ko at free.fr> wrote:
> Currently we can not search for more than one page in the "link="
> parameter,
> so in the third example "link=Cat1,Cat2" is just ignored. It would be
> really
> nice though, Patrick, if that became possible (also with
> negatives "link=Cat1,-Cat2").
Just checking... do you want "link=Cat1,Cat2" to mean "all pages with
links to either Cat1 or Cat2" or "all pages with links to both Cat1 and Cat2"?
> Petko, you can have multiple links matched in pagelists, if you're willing
> to patch function PageListTermsTargets() in pagelist.php:
> [...]
> if (@$opt['link']) { #!# JM-mod
> if(!is_array($opt['link']))
> $opt['link']=explode(',',$opt['link']);
> $link=array();
> foreach($opt['link'] as $l) {
> $link[] = MakePageName($pn, $l);
> $indexterms[] = " $l ";
> }
> $opt['=linkp'][] = "/(^|,)".implode('|',$link)."(,|$)/i";
> }
>
> I believe this can be turned into a recipy after recent pagelist.php
> refactorings.
The above code won't work, as $opt['=linkp'] cannot be an array.
Putting it as an array causes lots of "preg_match() expects parameter 1
to be a string" errors from PHP.
Removing the [] from the last line somewhat works -- but the code
above displays only those pages with links to both Cat1 and Cat2 to be
displayed. See the example using the above code (after fixing the [] error)
at:
http://www.pmichaud.com/sandbox/multilink/pmwiki.php?n=Main.HomePage
So, if the intent is to find pages that are in all of the link= targets
(i.e., the intersection and not the union), then the above will probably
work for that. However, I know a lot of people will expect or want
"link=Cat1,Cat2" to display pages having either Cat1 or Cat2 as targets.
> I hope no recipy is need, but that this instead gets included into pmwiki.
I'm planning to include this capability at some point, but I also want
to be able to handle negatives and wildcards. There's also the issue
that it needs to remain somewhat quick, which requires refactoring
the pageindex a bit (which is why the patch proposed above gives the
intersection instead of the union).
Pm
More information about the pmwiki-users
mailing list