BANS Mod - Default to Advanced Search

March 14, 2008 by Jon  
Filed under Build a Niche Store

I recently developed my first mod for the Build a Niche Store 3.0 software. The mod makes the advanced search options visible by default. Here’s what I mean:

BANS 3.0 Default Search

The image above shows the normal search that shows up on a default BANS 3.0 site. See how the search is rather basic? The only options are to type in a search phrase, decide if you want to include the title and description in your search, the area of the site to search from, and then the submit button.

However if you click the “Advanced” link, you’ll see all of the options shown in the image below:

BANS 3.0 Advanced Search

When the advanced options are enabled, your visitors get additional search fields such as min/max bids and price. The most important new search field is the ZIP code and miles from ZIP code option. This allows your visitors to search for items that are local to them.

The problem I see with the default approach to the advanced search is that it’s too hard on your site’s visitors. If local ZIP code searches are important to your niche, you don’t want to make it hard for your visitors to figure it out.

In my case, I just want to show the ZIP search by default, and not make them have to figure out to click the “Advanced” link. Trust me, 99% of visitors will not bother figuring that out. They’ll just move along to the next site if they don’t see what they need quickly.

So what my mod does is makes the advanced search visible by default. It makes the search–as shown in the second image above–the normal search on the page.

Disclaimer: this mod requires you to modify files on your site. Please make a backup of your site before you attempt to implement this mod. Also this mod requires BANS 3.0.

Here are the steps to apply this mod to your BANS 3.0 site:

Add this code to your FrontControl.php file:

function searchadvance(){

global $advanced,$srchdesc,$bin,$q,$sort,$catid,$maxprice,$minprice,$minbid,$maxbid,$page,$miles,$zip,$seller;
$fetch = new DB;
$fetch1 = new DB;
$fetch2 = new DB;
$fetch3 = new DB;
$fetch4 = new DB;
$fetch5 = new DB;
$fetch6 = new DB;

if($this->id != “”){
$id = $this->id;
} else {
$id = “”;
}
$f = ‘
<div id=”search”>
<form action=”‘.URL_PATH.’/search” style=”margin: 0px; padding: 0px;” method=”post” name=”search”>
<div>
<input name=”q” value=”" type=”text” class=”searchform” />
<select name=”id” id=”id”>’;
if ($id == ”){
$id = MAINCAT;
}
$fetch->q(”SELECT * FROM categories WHERE id = ‘”.$id.”‘ and display = ‘1′ order by page_order,cat_name asc”);
while($maininfo = $fetch->nx()){
$maininfo['cat_name'] = str_replace(”&”, “&”, $maininfo['cat_name']);
$f .= “<option value=’”.$maininfo['id'].”‘>> “.$maininfo['cat_name'].”</option>”;
if ($maininfo['id'] != MAINCAT){
$fetch1->q(”SELECT * FROM categories WHERE id = ‘”.$maininfo['parent_id'].”‘ and display = ‘1′ order by page_order,cat_name asc”) ;
while($maininfo1 = $fetch1->nx()){
$maininfo1['cat_name'] = str_replace(”&”, “&”, $maininfo1['cat_name']);
$f .= “<option value=’”.$maininfo1['id'].”‘>> “.$maininfo1['cat_name'].”</option>”;
if ($maininfo1['id'] != MAINCAT){
$fetch2->q(”SELECT * FROM categories WHERE id = ‘”.$maininfo1['parent_id'].”‘ and display = ‘1′ order by page_order,cat_name asc”) ;
while($maininfo2 = $fetch2->nx()){
$maininfo2['cat_name'] = str_replace(”&”, “&”, $maininfo2['cat_name']);
$f .= “<option value=’”.$maininfo2['id'].”‘>> “.$maininfo2['cat_name'].”</option>”;
if ($maininfo2['id'] != MAINCAT){
$fetch3->q(”SELECT * FROM categories WHERE id = ‘”.$maininfo2['parent_id'].”‘ and display = ‘1′ order by page_order,cat_name asc”) ;
while($maininfo3 = $fetch3->nx()){
$maininfo3['cat_name'] = str_replace(”&”, “&”, $maininfo3['cat_name']);
$f .= “<option value=’”.$maininfo3['id'].”‘>> “.$maininfo3['cat_name'].”</option>”;
if ($maininfo3['id'] != MAINCAT){
$fetch4->q(”SELECT * FROM categories WHERE id = ‘”.$maininfo3['parent_id'].”‘ and display = ‘1′ order by page_order,cat_name asc”) ;
while($maininfo4 = $fetch4->nx()){
$maininfo4['cat_name'] = str_replace(”&”, “&”, $maininfo4['cat_name']);
$f .= “<option value=’”.$maininfo4['id'].”‘>> “.$maininfo4['cat_name'].”</option>”;
if ($maininfo4['id'] != MAINCAT){
$fetch5->q(”SELECT * FROM categories WHERE id = ‘”.$maininfo4['parent_id'].”‘ and display = ‘1′ order by page_order,cat_name asc”) ;
while($maininfo5 = $fetch5->nx()){
$maininfo5['cat_name'] = str_replace(”&”, “&”, $maininfo5['cat_name']);
$f .= “<option value=’”.$maininfo5['id'].”‘>> “.$maininfo5['cat_name'].”</option>”;
if ($maininfo5['id'] != MAINCAT) {
$fetch6->q(”SELECT * FROM categories WHERE id = ‘”.$maininfo5['parent_id'].”‘ and display = ‘1′ order by page_order,cat_name asc”) ;
while($maininfo6 = $fetch6->nx()){
$maininfo6['cat_name'] = str_replace(”&”, “&”, $maininfo6['cat_name']);
$f .= “<option value=’”.$maininfo6['id'].”‘>> “.$maininfo6['cat_name'].”</option>”;
}
}
}
}
}
}
}
}
}
}
}
}
}
if(MAINCAT == ‘0′){
$f .= “<option value=’0′>> All Categories</option>”;
}
else if(MAINCAT == ‘2′){
$f .= “<option value=’0′>> All Categories</option>”;
}
$f .= “<option>———————————–</option>”;
$fetch->q(”SELECT * FROM categories WHERE parent_id = ‘”.MAINCAT.”‘ and display = ‘1′ order by page_order,cat_name asc”);
while($info = $fetch->nx()){
$info['cat_name'] = str_replace(”&”, “&”, $info['cat_name']);
$f .= “<option value=’”.$info['id'].”‘>”.$info['cat_name'] . “</option>”;
}
$f .= “<option>———————————–</option>”; {
$fetch->q(”SELECT * FROM categories WHERE id = ‘”.MAINCAT.”‘ and display = ‘1′ order by page_order,cat_name asc”) or die(mysql_error());
while($info = $fetch->nx()){
$info['cat_name'] = str_replace(”&”, “&”, $info['cat_name']);
$f .= “<option value=’”.$info['cat_id'].”‘>All “.$info['cat_name'].”</option>”;
}
}
$f .= ‘</select>
<input name=”searchit” value=”search” type=”submit” class=”searchsubmit” />
<input name=”sort” value=”‘.$this->sort.’” type=”hidden” />
<input name=”seller” value=”‘.$this->sellerid.’” type=”hidden” />
<input name=”fsoo” value=”‘.$this->fsoo.’” type=”hidden” />
<input name=”fsoo” value=”‘.$this->fsoo.’” type=”hidden” />
<input name=”catid” value=”‘.$this->catid.’” type=”hidden” />’;
if($srchdesc == ‘2′) {
$f .= ‘<p /><input name=”srchdesc” type=”checkbox” value=”2″ checked />Search title & description’;
}
else {
$f .= ‘<p /><input type=”checkbox” name=”srchdesc” value=”2″ />Search title & description’;
}
$f .= ‘<hr />’;
if($bin == ‘2′) $f .= ‘<p /><input name=”bin” type=”checkbox” value=”2″ checked />Buy It Now Items - ‘;
else $f .= ‘<p /><input type=”checkbox” name=”bin” value=”2″ />Buy It Now Items - ‘;
$f .=’ Min ‘.$this->currency().’ <input name=”minprice” type=”text” value=”‘.$minprice.’” size=”6″ /> Max ‘.$this->currency().’ <input name=”maxprice” type=”text” value=”‘.$maxprice.’” size=”6″ />’;
$f .=’ - Min Bid <input name=”minbid” type=”text” value=”‘.$minbid.’” size=”6″ /> Max Bid <input name=”maxbid” type=”text” value=”‘.$maxbid.’” size=”6″ />’;
$f .=’ - Miles <input name=”miles” type=”text” value=”‘.$miles.’” size=”6″ /> ZIP <input name=”zip” type=”text” value=”‘.$zip.’” size=”6″ />’;
$f .= ‘</div></form></div>’;
return $f;
}

Once you’ve added that to your FrontControl.php file, log into the admin section of your site and go to the Templates area.

Click to edit your template’s header.php file.

Find the following code:

<?=$front->search();?>

Replace that code with this:

<?=$front->searchadvance();?>

Save the header.php file and now your site should default to the advanced search at all times.

Here’s a breakdown of what this mod does…

  1. You added a new search function to your site. I basically took the default advanced search function that comes with BANS 3.0, and modified it so that it doesn’t require your visitors to click on a link to enable the extra search features.
  2. You found the code in your header.php file that calls up the normal, default search.
  3. You replaced that code, and instead told your header.php file to use the new advanced search function you added in the first step.

Not too complicated, and now you’ve just made things a lot easier for your visitors to use the advanced search features.

I hope you enjoy this mod!

If you enjoyed this post, make sure to subscribe to the RSS feed!

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Reddit
  • StumbleUpon
  • Technorati
  • TwitThis
Related Posts:

Comments

One Response to “BANS Mod - Default to Advanced Search”

  1. Magpie on April 2nd, 2008 6:52 am

    Thank you very much for this mod. =)

Feel free to leave a comment...
and oh, if you want a pic to show with your comment, go get a gravatar!