Hi,
I have a website which has been developed using PHP. Unfortunately relationship with web developer broke down 🙁 so I need some help with trying to remove a drop down on our home page.
To try to summarise the problem, the index.php and index.htm files have some code that drives a quick search box on the home page which has a drop down option with 4 choices, but I want to remove the drop down and just allow the search box to search across all 4 categories. However, the way it was coded means i can't easily change it to be a general search across all the 4 categories that we have, Activities, Events, Classes, Services.
here's the index.php section that refers to the quick search bit:
switch( $mode)
{
case 'quick_search':
$keyword = $_POST['txt_keyword'];
break;
}
$smarty->display('index.htm');
here's the index.htm bit:
<div id="quick_search">
<strong><span class="search_text">Quick Search</span></strong>
<form name="txt_quick_search" method="post">
<input type="hidden" name="mode" value="quick_search" />
<select name="txt_type">
<option value="activity">Activity</option>
<option value="service">Service</option>
<option value="class">Classes & Clubs</option>
<option value="event">Events</option>
</select>
<input name="txt_keyword" type="text" value="" size="11" />
<input value="Search" type="submit" class="button" />
</form>
</div>
There is an existing piece of code on another page for searching all the categories, and I was trying to see if I could use this. This is contained in search.php and search.htm.
Search.php code:
$mode = isset( $_GET['mode'] )?$_GET['mode']:'';
$mode = isset( $_POST['mode'] )?$_POST['mode']:$mode;
switch( $mode )
{
case '_search':
$keyword = $_POST['txt_search'];
$search_man = new CSearchManager( $keyword );
$smarty->assign('keyword',$keyword);
$smarty->assign('activity_cats',$search_man->SearchActivityCategory()); $smarty->assign('activity_location',$search_man->SearchActivityLocation()); $smarty->assign('service_cats',$search_man->SearchServiceCategory());
$smarty->assign('service_location',$search_man->SearchServiceLocation()); $smarty->assign('class_cats',$search_man->SearchClassCategory());
$smarty->assign('class_location',$search_man->SearchClassLocation());
break;
}
$smarty->assign('mode',$mode);
$smarty->display('search.htm');
Search.htm code:
<form name="search_activity" method="post" >
<input type="hidden" name="mode" value="_search" />
<table width="80%" border="0" cellpadding="0" cellspacing="0" class="search_bg">
<tbody>
<tr>
<td>Keyword</td>
<td ><input type="text" name="txt_search" size="40" value="{$keyword}" /></td>
<td><input type="submit" value="Search" class="btn" onmouseover="hov(this,'btn btnhov')" onmouseout="hov(this,'btn')" /></td>
</tr>
</tbody>
</table>
</form>
{if $mode=='_search'}
<div class="white">
<ul>
<li class="w_top"><img src="images/spacer.gif" alt="" /></li>
<li class="w_bg">
{if count($activity_cats) >0 || count($activity_location) > 0}
<table width="100%" border="0" cellspacing="3" cellpadding="0">
<tr>
<td><h2>Activity</h2></td>
</tr>
<tr>
<td>Categories:
{section name=i loop=$activity_cats}
<a href="javascript:return false" onclick="javascript:ShowSearchBox( 'category_activity','{$keyword}','{$activity_cats[i].category->m_cat_id}')">{$activity_cats[i].category->m_cat_name} ({$activity_cats[i].count})</a>
{/section}</td>
</tr>
<tr>
<td>Locations:
{section name=i loop=$activity_location}
<a href="javascript:return false" onclick="javascript:ShowSearchBox( 'location_activity','{$keyword}','{$activity_location[i].location->m_loc_id}')">{$activity_location[i].location->m_loc_name} ({$activity_location[i].count})</a>
{/section}</td>
</tr>
</table>
{/if}
{if count($service_cats ) >0 || count( $service_location) > 0}
<table width="100%" border="0" cellspacing="3" cellpadding="0">
<tr>
<td><h2>Service</h2></td>
</tr>
<tr>
<td>Categories:
{section name=i loop=$service_cats}
<a href="javascript:return false" onclick="javascript:ShowSearchBox( 'category_service','{$keyword}','{$service_cats[i].category->m_cat_id}')">{$service_cats[i].category->m_cat_name} ({$service_cats[i].count})</a>
{/section}</td>
</tr>
<tr>
<td>Locations:
{section name=i loop=$service_location}
<a href="javascript:return false" onclick="javascript:ShowSearchBox( 'location_service','{$keyword}','{$service_location[i].location->m_loc_id}')">{$service_location[i].location->m_loc_name} ({$service_location[i].count})</a>
{/section}
</td>
</tr>
</table>
{/if}
{if count($class_cats ) >0 || count( $class_location) > 0}
<table width="100%" border="0" cellspacing="3" cellpadding="0">
<tr>
<td><h2>Classes</h2></td>
</tr>
<tr>
<td>Categories:
{section name=i loop=$class_cats}
<a href="javascript:return false" onclick="javascript:ShowSearchBox( 'category_class','{$keyword}','{$class_cats[i].category->m_cat_id}')">{$class_cats[i].category->m_cat_name} ({$class_cats[i].count})</a>
{/section}</td>
</tr>
<tr>
<td>Locations:
{section name=i loop=$class_location}
<a href="javascript:return false" onclick="javascript:ShowSearchBox( 'location_class','{$keyword}','{$class_location[i].location->m_loc_id}')">{$class_location[i].location->m_loc_name} ({$class_location[i].count})</a>
{/section}
</td>
</tr>
</table>
{elseif count($activity_cats)+count($activity_location)+count($service_cats )+count( $service_location)+count($class_cats)+count( $class_location) ==0}
Sorry! Your search did not find a match in our listings database. Please try again.
{/if}
</li>
<li class="w_bot"><img src="images/spacer.gif" alt="" /></li>
</ul>
</div>
{/if}
Phew! I understand that the general search is complicated as it has to go through all entries in the database to see if it finds anything, but how can I add that type of search to my home page??
Any help is much appreciated.