<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body>
<br><br>&gt; Date: Mon, 2 Apr 2007 12:29:23 -0500<br>&gt; Subject: Re: [pmwiki-users] categories in pagelist<br>&gt; <br>&gt; On Mon, Apr 02, 2007 at 04:35:38PM +0000, J. Meijer wrote:<br>&gt; &gt;    On 4/1/07, Petko Yotov &lt;5ko@free.fr&gt; wrote:<br>&gt; &gt;      Currently we can not search for more than one page in the "link="<br>&gt; &gt;      parameter,<br>&gt; &gt;      so in the third example "link=Cat1,Cat2" is just ignored. It would be<br>&gt; &gt;      really<br>&gt; &gt;      nice though, Patrick, if that became possible (also with<br>&gt; &gt;      negatives "link=Cat1,-Cat2").<br>&gt; <br>&gt; Just checking...  do you want "link=Cat1,Cat2" to mean "all pages with <br>&gt; links to either Cat1 or Cat2" or "all pages with links to both Cat1 and Cat2"?<br>&gt; <br>&gt; &gt;    Petko, you can have multiple links matched in pagelists, if you're willing<br>&gt; &gt;    to patch function PageListTermsTargets() in pagelist.php:<br>&gt; &gt;    [...]<br>&gt; &gt;          if (@$opt['link']) { #!# JM-mod<br>&gt; &gt;            if(!is_array($opt['link']))<br>&gt; &gt;              $opt['link']=explode(',',$opt['link']);<br>&gt; &gt;            $link=array();<br>&gt; &gt;            foreach($opt['link'] as $l) {<br>&gt; &gt;              $link[] = MakePageName($pn, $l);<br>&gt; &gt;              $indexterms[] = " $l ";<br>&gt; &gt;            }<br>&gt; &gt;            $opt['=linkp'][] = "/(^|,)".implode('|',$link)."(,|$)/i";<br>&gt; &gt;          }<br>&gt; &gt; <br>&gt; &gt;    I believe this can be turned into a recipy after recent pagelist.php<br>&gt; &gt;    refactorings.<br>&gt; <br>&gt; The above code won't work, as $opt['=linkp'] cannot be an array.<br>&gt; Putting it as an array causes lots of "preg_match() expects parameter 1<br>&gt; to be a string" errors from PHP.<br>&gt; <br><br><br>That's correct, I forgot the second patch (it wasn't as clearly marked!):<br><br>&nbsp;&nbsp;&nbsp; case PAGELIST_ITEM:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!$page) { $page = ReadPage($pn, READPAGE_CURRENT); $opt['=readc']++; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!$page) return 0;<br>## changed section:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (@$opt['=linkp']) { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach($opt['=linkp'] as $l) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(preg_match($l, @$page['targets'])) { $l=0; break; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if($l) { # no link matched<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $opt['=reindex'][] = $pn; return 0; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br><br>&gt; Removing the [] from the last line somewhat works -- but the code<br>&gt; above displays only those pages with links to both Cat1 and Cat2 to be <br>&gt; displayed.  See the example using the above code (after fixing the [] error) <br>&gt; at:<br>&gt; <br>&gt;     http://www.pmichaud.com/sandbox/multilink/pmwiki.php?n=Main.HomePage<br>&gt; <br>&gt; So, if the intent is to find pages that are in all of the link= targets<br>&gt; (i.e., the intersection and not the union), then the above will probably<br>&gt; work for that.  However, I know a lot of people will expect or want<br>&gt; "link=Cat1,Cat2" to display pages having either Cat1 or Cat2 as targets.<br>&gt; <br>&gt; <br>&gt; &gt;    I hope no recipy is need, but that this instead gets included into pmwiki.<br>&gt; <br>&gt; I'm planning to include this capability at some point, but I also want<br>&gt; to be able to handle negatives and wildcards.  There's also the issue<br>&gt; that it needs to remain somewhat quick, which requires refactoring<br>&gt; the pageindex a bit (which is why the patch proposed above gives the<br>&gt; intersection instead of the union).<br><br>The link intersection is the highly desired capability needed to give me virtual hierarchy capability using categories. I was doing some experiments here. <br><br><br>I think that instead of the link=+xx and link=-yyy syntax there is the option to have this:<br><br>&nbsp; ## get a pages with xxx AND yyy (as I did implement):<br>&nbsp; (:pagelist link=xxx,yyy:)<br>&nbsp; ## get pages with xxx OR yyy:<br>
&nbsp; (:pagelist link=xxx link=yyy:)<br>&nbsp; ## get pages with xxx OR both yyy and zzz<br>


&nbsp; (:pagelist link=xxx link=yyy,zzz:)<br>


<br>Don't know how this'll conflict with user expectations, but I find it quite acceptable. Maybe you'd like interchange the and &amp; or semantics. <br><br><br>/jm<br><br>&gt; <br>&gt; Pm<br>&gt; <br><br><br><br><br><br><br>ps On the topic of semantics Pm wrote<br><br><div style="direction: ltr;">&gt; I think this is inconsistent with the other filters -- consider<br><br> &nbsp; &nbsp;1. &nbsp;group=PmWiki,Site<br> &nbsp; &nbsp;2. &nbsp;name=Test*,XYZ*<br> &nbsp; &nbsp;3. &nbsp;$:Status=open,closed,pending<br><br>&gt; We expect these to mean<br><br> &nbsp; &nbsp;1. &nbsp;pages in either the PmWiki or Site groups<br> &nbsp; &nbsp;2. &nbsp;pages that begin with either "Test" or "XYZ"<br> &nbsp; &nbsp;3. &nbsp;pages with $:Status of open, closed, or pending<br><br>&gt; Thus, to be consistent with the above, I would think that "link=Cat1,Cat2"<br>&gt; should mean "pages with links to either Cat1 or Cat2".<br><br>It is this way because a group *can't* be 2 groups at a time. Likewise Name, likewise $:Status. <br><br></div><span class="q">But a page can easily have several backlinks (meaning "on a certain domain"). I believe that is the real application here. Those seeking this capability have expectancies that *may* differ from the suggestion arising from the above presentation.. <br></span><br><br>---<br><br>I haven't thought any of the combinations through. It certainly will be yet another key capability to have. Thanks!<br><br><br><br><br><br /><hr />It’s tax season, make sure to follow these few simple tips  <a href='http://articles.moneycentral.msn.com/Taxes/PreparationTips/PreparationTips.aspx?icid=WLMartagline' target='_new'>Check it out!</a></body>
</html>