[pmwiki-users] Quick pagename search?

Patrick R. Michaud pmichaud at pobox.com
Thu Mar 1 13:09:35 CST 2007


On Thu, Mar 01, 2007 at 07:56:21PM +0100, Oliver Betz wrote:
> Patrick R. Michaud wrote:
> 
> > > how can I get a pagename substring search box instead of or in 
> > > addition to the full text search box?
> > > 
> > > I know that I can enter "name=*term*" in the default searchbox, but 
> > > that's inconvenient, and many users can't remember it.
> > 
> > How would you like to specify a pagename substring search box?
> 
> One possibility would be to extend the (:searchbox:) directive with a 
> (pseudo) variable for the search term, e.g. the "q" already used as 
> HTTP GET variable. This way one could put some text around the user 
> entry, like "name=*$q*". Maybe there are other uses for this.

We've discussed having variables for query terms... but I don't
think that really solves the problem in a robust way.  What if 
$q has spaces in it, or represents multiple terms, or has other 
options included in it?

I think my question is a bit broader than the answer given here...
I'm not really asking how to make it work within the directives
available -- I'm asking "how should it look"?  In particular,
if (:searchbox:) is what we use to search page contents, perhaps
something like (:pagebox:) or (:titlesearch:) or something like
that is the way to go.

Or perhaps we just specify a pagelist option that identifies
what is to be searched by the search terms.  PmWiki's current
default would be "name,text,targets", but we could have an
option that limits the search to titles or names:

    (:searchbox fields=name:)

> The "put me directly to the page if there is only one hit" behaviour 
> might indeed require another option. What about making $MatchCount / 
> {$$PageCount} accessible as page variable, then one could make a 
> conditional redirect?

{$$PageCount} is already a page variable.  Thus, I think it would work 
to have the following in a pagelist template (using the new syntax):

    (:template last:)
    (:if equal {$$PageCount} 1:)(:redirect {=$FullName}:)

So, if there's only one page in the results, the browser is 
immediately redirected to it.  

Using PmWiki's existing template syntax, this would be:

    (:if expr equal {>$Group} "" && equal {$$PageCount} 1 :)
    (:redirect {=$FullName}:)

Pm



More information about the pmwiki-users mailing list