For EE1.x.x only, though may be adaptable to EE2
Allow for drop-down driven searches by editing the file, core.regex.php
Replace this code segment near the bottom of core.regex.php:
/** ----------------------------------------
/** Clean Keywords - used for searching
/** ----------------------------------------*/
function keyword_clean($str)
{
$str = strtolower($str);
$str = strip_tags($str);
... with this improvement that allows drop-down menu driven searches to exist, such as on this and all other flower detail pages at NCWildflower.org, for example.
/** ----------------------------------------
/** Clean Keywords - used for searching
/** ----------------------------------------*/
function keyword_clean($str)
{
if (is_array($str)) {
$str = implode(' ',$str);
}
$str = strtolower($str);
$str = strip_tags($str);
Here is my own test code snippet modifying the simple search form. Note how it uses name=“keywords[]” - the brackets designate a result that will employ concatenation:
{exp:search:simple_form weblog="plants" search_in="everywhere" where="all"}
<p><label for="keywords">Search:</label><br />
<input type="textarea" name="keywords[]" id="keywords" value="" size="18" maxlength="100" /></p>
<input type="textarea" name="keywords[]" id="keywords" value="" size="18" maxlength="100" /></p>
<p><input type="submit" value="submit" class="submit" /></p>
{/exp:search:simple_form}
And here is the actual code being used to make the search drop-downs work at NCWildflower.org (I implemented it as an embedded template):
{exp:search:simple_form weblog="plants" search_in="everywhere" where="all"}
<p><i>(This mini-search is still an experimental feature - give it a try! <br />For instance, find a plant that already thrives in your garden, and enter some of the same criteria to find others similar. <br />See also our <a href="http://www.ncwildflower.org/natives/recommend.htm">Recommended Plants section!</a>)</i><br /><br /></p>
<ul class="nav">
<li>
<label for="plant_type">Plant Type:</label>
<select name="keywords[]" >
<option value="">Nothing Selected</option>
<option value="Undetermined">Undetermined</option>
<option value="Deciduous Tree">Deciduous Tree</option>
<option value="Evergreen Tree">Evergreen Tree</option>
<option value="Shrub / Tree">Shrub / Tree</option>
<option value="Shrub -tree -shrubby">Shrub</option>
<option value="Deciduous Shrub">Deciduous Shrub</option>
<option value="Large Evergreen Shrub">Large Evergreen Shrub</option>
<option value="Vine -ravine -Shrubby">Vine</option>
<option value="(Shrubby) Vine">(Shrubby) Vine</option>
<option value="Fern">Fern</option>
<option value="Perennial">Perennial</option>
<option value="Perennial (Shrubby) Groundcover">Perennial (Shrubby) Groundcover</option>
<option value="Biennial -annual">Biennial</option>
<option value="Annual -biennial">Annual</option>
<option value="Annual/Biennial">Annual/Biennial</option>
</select></li>
<li>
<label for="light">Light:</label>
<select name="keywords[]" >
<option value="">Nothing Selected</option>
<option value="Full-Sun">Full Sun</option>
<option value="Part-Sun">Part Sun</option>
<option value="Sun -full-sun -part -sunflower -sundrops">Sun</option>
<option value="Sun part shade">Sun - Part Shade</option>
<option value="Shade">Shade</option>
</select>
<br /></li>
<li>
<label for="moisture">Moisture: <a >(Chart)</a></label>
<select name="keywords[]" >
<option value="">Nothing Selected</option>
<option value="hydric -sub-hydric">Hydric (wet)</option>
<option value="sub-hydric">Sub-Hydric (quite moist)</option>
<option value="hygric -sub-hygric">Hygric (mostly moist)</option>
<option value="sub-hygric">Sub-Hygric (often moist)</option>
<option value="mesic -sub-mesic">Mesic (adequately moist)</option>
<option value="sub-mesic">Sub-Mesic (high drainage}</option>
<option value="sub-xeric">Sub-Xeric (moist to dry)</option>
<option value="xeric -sub-xeric -very-xeric">Xeric (dry)</option>
<option value="very-xeric">Very Xeric (very dry)</option>
</select></li>
<li>
<label for="bloom_time">Bloom Time:</label>
<select name="keywords[]" >
<option value="">Nothing Selected</option>
<option value="spring">Spring</option>
<option value="february">February</option>
<option value="march">March</option>
<option value="april">April</option>
<option value="may">May</option>
<option value="summer">Summer</option>
<option value="june">June</option>
<option value="july">July</option>
<option value="august">August</option>
<option value="fall">Autumn</option>
<option value="september">September</option>
<option value="october">October</option>
<option value="november">November</option>
<option value="winter">Winter</option>
<option value="december">December</option>
<option value="January">January</option>
</select></li>
<li><label for="Natives Only">Natives Only:</label><input type="checkbox" name="keywords[]" id="keywords" maxlength="6" value="native" /></li>
<br />
<li><input type="submit" value="submit" class="submit" /></li>
</ul>
{/exp:search:simple_form}
See the first post by yehosef here and a discussion of the drop-down driven search here.
Terry Leigh Britton
Category:Search
Category:Hacks
Category:Coding
Category:EE1
