[pmwiki-users] searchbox and searchresults ideas

Hans design at softflow.co.uk
Mon Jan 2 04:41:39 CST 2006


From thread "search not working":
Saturday, December 31, 2005, 8:12:57 PM, Patrick wrote:
>> >1.  Add an option to (:searchbox:) to tell it which page
>> >    (instead of Site.Search) to use to display search results.
>> >
>> >2.  Modify ?action=search so that if the current page has
>> >    a (:searchresults:) on it, then use it to display the
>> >    search results instead of Site.Search.
>> >
> For #1 we need to define two options (and I need to know
> appropriate names for each).

> One option needs to allow the author to say "have the search
> land on XYZ page instead of the current page."

> The other option needs to allow the author to say "display the
> results of ?action=search using XYZ page instead of Site.Search".

I suggest to add to the searchbox options the keys "template" and
"target".

template= option:
As default it uses, if exists, and in this order:
     $[$Group.Search],  $[$SiteGroup.Search]
otherwise the page named after template= in the markup, for instance:
     template=Group.CustomSearch

target= option
As default it uses the current page, otherwise the page named after
target= in the markup, for instance target=Site.Search  to redirect
the search results to Site.Search.

In addition action=search should use (:searchresults:) if it exists on
the target page, which would enable formatting of search results in
the same way as with (:pagelist:) (#2 from above). If
(:searchresults:) does not exist then it will use it from the default
page $Group.Search or $SiteGroup.Search respectively (like the
template option).

Thinking further about (:searchbox:):
While it is possible to redefine it with $SearchBoxFmt, I found it
difficult to do if I wanted to preserve the various options.
It would be a lot easier to modify the default a little.
So while we are looking at it my wish is to have two additions:

1. Adding two addition style classes:
   class='inputbox wikisearchbox' to <input type='text'>.
   class='inputbutton wikisearchbutton' to <input type='submit'>.
This provides hooks for skin css to give more general styles for
buttons and input boxes. I use it on (:newpagebox:), (:searchbox:) and
the buttons of the edit form etc.

2. Adding an option focus= to insert optionally onfocus and onblur
javascript snippets for any "value" appearing in the box.
focus=true or focus=blur or any other word will enable the
onfocus and onblur snippet. The default is the code is not inserted.
code:
$focus = $opt['focus'];
if ($focus)
 $out .= "onfocus=\"if(this.value=' {$opt['value']} ') {this.value=''}\"
        onblur=\"if(this.value=='') {this.value=' {$opt['value']} '}\" ";

        
Finally this brings me to a side question:
If I enable onfocus and onblur in the input forms by adding it to
$InputAttrs, by setting for instance in config.php:
   include_once("$FarmD/scripts/forms.php");
   $InputAttrs[] = 'onfocus';
   $InputAttrs[] = 'onblur';
then I could create forms with (:input:) markup an dinclude these
javascript snippets.
Does this pose great security risks, as it enables javascript code to
be added to these events attached to input forms?


Best, 
~Hans                           






More information about the pmwiki-users mailing list