[pmwiki-users] Fox Contacts Search

Peter Bowers pbowers at pobox.com
Tue Apr 6 06:54:12 CDT 2010


On Wed, Mar 31, 2010 at 2:14 PM, Vince Administration
<vadmin at math.uconn.edu> wrote:
> Is it possible to easily construct a search form that is essentially the new contact form, where the user would fill in the fields that he/she wished to search for, for example
> those on Maple Street, or those with first name Joe and address containing a 164.  What I would really like is a form that looks like the new contact form, but does a search with the values that are filled in.

Can you just make a new markup (:contactsearch:) which builds the
"(:pagelist ...:)" string and replaces itself with that string?

Something like this:

===(snip)===
Markup("contactsearchresults", "<pagelist",
"/\(:contactsearchresults:\)/ie", "contactsearchresults()");

function contactsearchresults()
{
   if (!isset($_REQUEST['ContactSearchButton'])) return('');
   $rtn = '(:pagelist ';
   # This array has the field name in your contact search form as the
index and the field
   # name in your contact database as the value -- there are
undoubtedly better ways to
   # do it...
   $valid_fields = array('fname'=>'$:fname', 'lname'=>'$:last_name',
'addr1'=>'$:address1');
   foreach ($_REQUEST as $f => $v) {
      if ($valid_fields[$f] && $v) {
         $rtn .= $valid_fields[$f].'="'.$v.'" ';
      }
   }
   return($rtn);
}
===(snip)===

It probably won't even compile without some work but with a little
work it should take care of the problem of the blank values as well as
giving pretty good extensibility if you decide to do something special
with certain fields or something...

(Make sure on your form you have ContactSearchButton as the name of
your main search submission button or else modify that first line in
the function.)

-Peter



More information about the pmwiki-users mailing list