[pmwiki-users] Quick pagename search?

0 views
Skip to first unread message

Oliver Betz

unread,
Mar 1, 2007, 3:48:28 AM3/1/07
to pmwiki...@pmichaud.com
Hello All,

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.

There were some discussions about this, but I found no "ready to use"
solution.

Oliver
--
Oliver Betz, Muenchen


_______________________________________________
pmwiki-users mailing list
pmwiki...@pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Oliver Betz

unread,
Mar 1, 2007, 1:15:01 PM3/1/07
to pmwiki...@pmichaud.com
update:

> how can I get a pagename substring search box instead of or in
> addition to the full text search box?

well, I hacked it, but I don't like it. Any hints to make it cleaner
are welcome.

An input form calls a TitleSearch page where I use the HTTP GET
variable to form the correct search pattern:

(:input form method=get action={$ScriptUrl}/Site/TitleSearch:)
(:input text name=tsq:)
(:input end:)

And TitleSearch contains:
(:if !equal {$tsq} '':)
(:pagelist name=*{$tsq}*:)
(:ifend:)

Since I didn't know a better way to access GET variables, I added
$FmtPV['$tsq'] = htmlspecialchars($_GET['tsq']);
to config.php. I feel there has to be a cleaner way, any hint?


Besides this, I would prefer a title search with additional
functionality like in PhpWiki: if there is only one matching page,
the user should be forwarded directly to this page.

This is a very conventient navigation method - you need little
keystrokes and mouse clicks if you know a unique part of the
pagename.

For example, if you have to edit the "DocumentationIndex" repeatedly,
it could be sufficient to type "oni" in the TitleSearch field. I use
this all the time in my PhpWiki and wouldn't like to miss it.

Patrick R. Michaud

unread,
Mar 1, 2007, 1:20:50 PM3/1/07
to Oliver Betz, pmwiki...@pmichaud.com
On Thu, Mar 01, 2007 at 09:48:28AM +0100, Oliver Betz wrote:
> Hello All,
>
> 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?

In other words, what sort of markup or option to pagelist would
make the most sense to you (as an author) to mean "do a search
of pagenames only"?

Implementation for this is very easy -- all I need is a suitable
markup.

Pm

Oliver Betz

unread,
Mar 1, 2007, 1:56:21 PM3/1/07
to Patrick R. Michaud, pmwiki...@pmichaud.com
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.

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?

Oliver
--
Oliver Betz, Muenchen

Patrick R. Michaud

unread,
Mar 1, 2007, 2:09:35 PM3/1/07
to Oliver Betz, pmwiki...@pmichaud.com
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

Hans

unread,
Mar 1, 2007, 2:32:00 PM3/1/07
to pmwiki...@pmichaud.com
Thursday, March 1, 2007, 7:09:35 PM, Patrick wrote:

> 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:)

This would be great. It avoids needing another markup for this.

The word "field" may look a little strange. It refers to the page file
lines, i.e. $page['name'], $page['text'] etc ?
When I hear "fields" I think of forms. The page file structure is not
normally referred to. Technically they are $page array values I guess?
I just don't know what we call these, but perhaps there is a better
term than "fields".


Hans

Patrick R. Michaud

unread,
Mar 1, 2007, 2:48:31 PM3/1/07
to Hans, pmwiki...@pmichaud.com
On Thu, Mar 01, 2007 at 07:32:00PM +0000, Hans wrote:
> Thursday, March 1, 2007, 7:09:35 PM, Patrick wrote:
>
> > 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:)
>
> This would be great. It avoids needing another markup for this.
>
> The word "field" may look a little strange. It refers to the page file
> lines, i.e. $page['name'], $page['text'] etc ?
> When I hear "fields" I think of forms. The page file structure is not
> normally referred to. Technically they are $page array values I guess?
> I just don't know what we call these, but perhaps there is a better
> term than "fields".

The page array values are called "attributes", but I wasn't
necessarily limiting the "fields=" parameter to page attributes.
In other words, it may also be that we want to allow page variables
to appear here, as in:

## search for terms in pagenames and $:Summary
(:searchbox fields=name,$:Summary:)

Yes, this would give us two different ways to select pages
based on page variables... but what's wrong with that? ;-)

I agree that a term other than "fields" would be better -- that's
all I could come up with on short notice. But I'm also not
intending to limit it to $page array values.

Pm

Hans

unread,
Mar 1, 2007, 3:03:03 PM3/1/07
to pmwiki...@pmichaud.com
Thursday, March 1, 2007, 7:48:31 PM, Patrick wrote:

> I agree that a term other than "fields" would be better -- that's
> all I could come up with on short notice. But I'm also not
> intending to limit it to $page array values.

trying to brainstorm:

scope
area
zone


Hans

Kathryn Andersen

unread,
Mar 1, 2007, 3:21:22 PM3/1/07
to pmwiki...@pmichaud.com
On Thu, Mar 01, 2007 at 01:48:31PM -0600, Patrick R. Michaud wrote:
> The page array values are called "attributes", but I wasn't
> necessarily limiting the "fields=" parameter to page attributes.
> In other words, it may also be that we want to allow page variables
> to appear here, as in:
>
> ## search for terms in pagenames and $:Summary
> (:searchbox fields=name,$:Summary:)
>
> Yes, this would give us two different ways to select pages
> based on page variables... but what's wrong with that? ;-)
>
> I agree that a term other than "fields" would be better -- that's
> all I could come up with on short notice. But I'm also not
> intending to limit it to $page array values.

Well why not the word you just used above in the comment?
-> "terms"

Kathryn Andersen
--
_--_|\ | Kathryn Andersen <http://www.katspace.com>
/ \ |
\_.--.*/ | GenFicCrit mailing list <http://www.katspace.com/gen_fic_crit/>
v |
------------| Melbourne -> Victoria -> Australia -> Southern Hemisphere
Maranatha! | -> Earth -> Sol -> Milky Way Galaxy -> Universe

Hans

unread,
Mar 1, 2007, 3:24:50 PM3/1/07
to Kathryn Andersen, pmwiki...@pmichaud.com
Thursday, March 1, 2007, 8:21:22 PM, Kathryn wrote:

> Well why not the word you just used above in the comment?
->> "terms"

but "terms" is what you put into the searchbox. It is the scope
of the search which gets defined, or set, or limited.


Hans

Oliver Betz

unread,
Mar 2, 2007, 4:32:54 AM3/2/07
to Patrick R. Michaud, pmwiki...@pmichaud.com
Patrick R. Michaud wrote:

[...]

> > > 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 see - my workaround is not robust.

> 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:)

which would be more flexible as far as I see.

> > 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):

o.k. - I didn't realize that it has to be in a template to be valid.

> (: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}:)

the redirect doesn't seem to work - it's simply displayed as
(:redirect PmWiki.SomePage:).

For a "production" version I would also dislike a "(redirected from"
message in the target page.

Oliver
--
Oliver Betz, Muenchen

Patrick R. Michaud

unread,
Mar 2, 2007, 9:59:05 AM3/2/07
to Oliver Betz, pmwiki...@pmichaud.com
On Fri, Mar 02, 2007 at 10:32:54AM +0100, Oliver Betz wrote:
> > (:if expr equal {>$Group} "" && equal {$$PageCount} 1 :)
> > (:redirect {=$FullName}:)
>
> the redirect doesn't seem to work - it's simply displayed as
> (:redirect PmWiki.SomePage:).

Ah, you're correct -- redirects aren't currently enabled within
pagelists. I'll add this capability.

> For a "production" version I would also dislike a "(redirected from"
> message in the target page.

One can turn off the "redirected from" message entirely by using

$PageRedirectFmt = '';

Pm

Reply all
Reply to author
Forward
0 new messages