Advanced Search Form
From Adult Web Scripts Wiki
This is an example for the dating module, but the same idea (and almost the same code) will also work for the webcams module.
URL Config
First thing is to add a new urlconfig item to load the new advanced search form. Add an entry as follows:
- name: dating_search
- rule: /dating-search/
- type: none
This will then load dating_search.php (or dating_search.tpl etc) when the url mydomain.com/dating-search/ is requested.
Theme File
This code will first display a search form and then display results when the form has been submitted. Save as dating_search.php. It assumes you have a header.php and footer.php for your current theme, if not change to suit.
This code needs at least zestoi version 1.2.2 for the zestoi_list_vals() function.
<? echo zestoi_template('header.php'); if (isset($_GET['page'])): $args = array('page' => $_GET['page']); // args: simple choices foreach (array('kw', 'site', 'city', 'country', 'eye_color', 'hair_color') as $name) { if (!empty($_GET[$name])) $args[$name] = $_GET[$name]; } // args: ranges foreach (array('age', 'height', 'weight') as $name) { if (!empty($_GET[$name . '_from']) && !empty($_GET[$name . '_to'])) { $args[$name] = $_GET[$name . '_from'] . '..' . $_GET[$name . '_to']; } elseif (!empty($_GET[$name . '_from'])) { $args[$name] = $_GET[$name . '_from'] . '..'; } elseif (!empty($_GET[$name . '_to'])) { $args[$name] = '..' . $_GET[$name . '_to']; } } // extract the results - up to 100 rows $html = zestoi('dating', $args); // display results or a no-results-found message if (zestoi_val('matches') > 0) { // print out a navbar $num_pages = zestoi_val('num_pages'); for ($pageloop=1; $pageloop<$num_pages; $pageloop++) { $_GET['page'] = $pageloop; echo '<a href="?' . Zestoi::array2url($_GET) . '">' . $pageloop . '</a> '; } // print out the search results echo $html; } else { echo "<p>No Matches Found</p>"; } else: // display the search form $cities = zestoi_list_vals('dating', 'city'); $countries = zestoi_list_vals('dating', 'country'); $ages = zestoi_list_vals('dating', 'age'); $hair_colors = zestoi_list_vals('dating', 'hair_color'); $eye_colors = zestoi_list_vals('dating', 'eye_color'); $heights = zestoi_list_vals('dating', 'height'); $weights = zestoi_list_vals('dating', 'weight'); $sites = zestoi_list_vals('dating', 'site'); ?> <form method="GET"> <table bgcolor="white"> <tr><th colspan="2">Dating Advanced Search</th></tr> <tr><th>Keywords</th><td><input name="kw" type="text" size="30" value=""></td></tr> <tr><th>City</th><td><select name="city"> <option></option> <? foreach ($cities as $city): ?> <option value="<?= $city['url_name'] ?>"><?= $city['name'] ?></option> <? endforeach; ?> </select></td></tr> <tr><th>Country</th><td><select name="country"> <option></option> <? foreach ($countries as $country): ?> <option value="<?= $country['url_name'] ?>"><?= $country['name'] ?></option> <? endforeach; ?> </select></td></tr> <tr><th>Age</th><td> from <select name="age_from"> <option></option> <? foreach ($ages as $age): ?> <option value="<?= $age['url_name'] ?>"><?= $age['name'] ?></option> <? endforeach; ?> </select> to <select name="age_to"> <option></option> <? foreach ($ages as $age): ?> <option value="<?= $age['url_name'] ?>"><?= $age['name'] ?></option> <? endforeach; ?> </select> </td></tr> <tr><th>Hair Color</th><td><select name="hair_color"> <option></option> <? foreach ($hair_colors as $hair_color): ?> <option value="<?= $hair_color['url_name'] ?>"><?= $hair_color['name'] ?></option> <? endforeach; ?> </select></td></tr> <tr><th>Eye Color</th><td><select name="eye_color"> <option></option> <? foreach ($eye_colors as $eye_color): ?> <option value="<?= $eye_color['url_name'] ?>"><?= $eye_color['name'] ?></option> <? endforeach; ?> </select></td></tr> <tr><th>Height</th><td> from <select name="height_from"> <option></option> <? foreach ($heights as $height): ?> <option value="<?= $height['url_name'] ?>"><?= $height['name'] ?></option> <? endforeach; ?> </select> inches to <select name="height_to"> <option></option> <? foreach ($heights as $height): ?> <option value="<?= $height['url_name'] ?>"><?= $height['name'] ?></option> <? endforeach; ?> </select> inches </td></tr> <tr><th>Weight</th><td> from <select name="weight_from"> <option></option> <? foreach ($weights as $weight): ?> <option value="<?= $weight['url_name'] ?>"><?= $weight['name'] ?></option> <? endforeach; ?> </select> lbs to <select name="weight_to"> <option></option> <? foreach ($weights as $weight): ?> <option value="<?= $weight['url_name'] ?>"><?= $weight['name'] ?></option> <? endforeach; ?> </select> lbs </td></tr> <tr><th>Site</th><td><select name="site"> <option></option> <? foreach ($sites as $site): ?> <option value="<?= $site['url_name'] ?>"><?= $site['name'] ?></option> <? endforeach; ?> </select></td></tr> <tr><th colspan="2"><input type="submit" value=" Search "></th></tr> </table> <input type="hidden" name="page" value="1"> </form> <? endif; ?> <?= zestoi_template('footer.php'); ?>
