[pmwiki-devel] Idea: Make the search results list categories of each matching page

Martin Fick mogulguy at yahoo.com
Tue Dec 26 12:44:54 CST 2006

--- christian.ridderstrom at gmail.com wrote:
> On Sun, 24 Dec 2006, Crisses wrote:
> >> While talking to a friend this evening over
> bears, we had the idea that 
> >> it could be useful if the default search results
> displayed the 
> >> categories each matching page belongs to.
> >
> > This is already possible on any page you do
> something like this:

There is another solution that doesn't require authors
to follow the Categories: convention.  

Use a nested pagelist template with the
pagelistextensions 'targets=' feature and a filtering
pagelist template.  While this recipe is a little
outdated and may not integrate well with the new beta
series (I haven't tried that yet), Patrick was talking
about adding such a feature to the beta series at one

This would be the top level (search) pagelist

(:pagelist targets={=$FullName} fmt=#CategoryList:)

The 'targets=' option gets a list of all the (page)
targets on a page similar to what the 'trail=' option
does, but not just the targets that are properly
formatted to be on a trail.  This should give you a
list which includes all the Categories on the page. 
This second (inner) pagelist template then filters out
all non Category pages.

* [[{=$$targets}]] \
(:if expr ! equal {<$Group} {=$Group} AND equal
{=$Group} Category :)\
(:if equal {=$Group} Category :)\
(:if expr equal {>$Group} {=$Group} AND equal
{=$Group} Category :)\
, \
(:if expr ! equal {>$Group} {=$Group} AND equal
{=$Group} Category :)\

The * [[{=$$targets}]] takes advantage of the pagelist
options to get the current pagename in the outter
pagelist template.  The first 'if' should add the
leading paren if any categories exists, the fourth
'if' should terminate the parens.  The second 'if'
should list out the categories while the third 'if'
should add commas between them.  This specific
template is untested, but I have done very similar
things on my site,


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the pmwiki-devel mailing list