Sidebar

startup_tutorial_and_checklist:feature_configuration:search_configuration:custom_search_form

Create Your Own Custom Search Form

The software has a search module that will allow you to quickly place a search form within your Geo managed design without needing to create your own search form from scratch. But if that feature doesn't provide enough flexibility or especially if you wish to place a search form outside the Geo software this tutorial would help. You can see more about the search box 1 module here.

You can create a search form anywhere within your design you like. You only need the basic html form elements that will be shown here to do so. Once this form is created you can place it anywhere in your site design inside the design managed by your Geo software or outside it on other places within or without your site. You can place search forms on other sites. You are essentially going to recreate the form the script creates within the advanced search page. Your form can be a simple search term box with a search button or complex with many fields to limit results by. Look at the html source of the advanced search form as it is created on the fly by the software in the advanced search feature reached at "index.php?a=19" of your Geo software. If you still use the default design you can click the search button in the header or footer to get therem. This will contain all of the basic "form elements" that will need to be within your custom search form. The most basic search form would look like:

<form action="index.php?a=19" method="get">
<input type="hidden" name="a" value="19">
<input type="text" name="b[search_text]">
<input type="submit" value="search">
</form>

You could place the above anywhere within the default design managed by your Geo software. You could place that same form within other html pages of your site but make sure that form submission goes to your Geo software installation. If your software were installed at the root of "example.com" then the above simple form would look like:

<form action="http://example.com/index.php?a=19" method="get">
<input type="hidden" name="a" value="19">
<input type="text" name="b[search_text]">
<input type="submit" value="search">
</form>

From here you can add specific elements to focus the search you are trying to create. Below should help explain how to enhance the basic search form above to search specific fields or categories using additional values submitted within the search form.

The search form can conceivably be anywhere on the Internet but will need to submit to the search functionality within the software. Firstly, you will need to create a basic form that submits to the "index.php?a=19" (or other "lead" file you have set for your installation but always with the "?a=19" query string element). This form can then be placed anywhere in its own page template, extra page, or html module of the software design…or in any html on any site. But if you place the search form on any other website you will need to make sure the url you submit the search form to has the address of your script including the domain name if needed as described in the second example form above.

<tip c n>Note that where ever you place this form in your Geo managed design, somewhere else on your site or somewhere else on the Internet that form will submit to the Geo software. That means the client will go to the url of the Geo software search tool and will see their search results within that feature. So if you placed the above form at abc.com site and your Geo software is at example.com the client will be directed to the example.com site and the search results will display in the Geo search feature.</tip>

The software comes by default having the index.php file as the root file that all functions are initiated. If you have changed this then you will need to not use index.php as below but the file name that you have changed it to. For example purposes the below form is set using index.php.

Category Specific Search Forms

You can create custom search forms on a category by category basis. This allows you to use one search form throughout most or just a few of your categories yet still have category specific search forms for specific categories that need them. You would make the configurations needed to set category specific search forms in the following admin tool:

CATEGORIES > CATEGORY SETUP

But note that once you turn off the use of the default search form within the admin tool the search form turns off site wide. So even though you may only need category specific search forms for a few categories you will still need to create a custom one for the "site wide default" search form attached to the search and search results page itself so that all categories that do not have a custom search form still have a search form.

Category Specific Fields in Category Specific Search Forms

You have the ability to add category specific fields from category specific fields used within that category or site wide optional fields if used site wide or configured for use in that specific category. But note that if you add "question/search fields" to a category specific form just make sure those fields added are "on" within the category you are creating the category specific search form for. Otherwise you could be having your clients search fields with criteria that can never return results in a search.

Site wide optional fields are covered in more detail further on within this wiki page.

Category specific fields can be added but note these fields are optional to the seller and may not contain any results. So using them in a search criteria might guarantee no results depending your sellers zealousness in answering category specific questions. But to add one of these types of questions to a category specific search form you only need to look at the html source within the default advanced search form. All category specific questions have a unique id attached to each and you would need to find that id within the html source of the advanced search form when they appear. The basic form for a blank field category question is:

<input name="b[question_value][###]" type="text">

and for dropdown type category specific fields:

<select name="b[question_value][###]>
<option></option>
<option>one</option>
<option>two</option>
<option>three</option>
<option>four</option>
</select>

Where "###" in the code above would be the question id you find for that question in the html source of the advanced search page when those questions are present.

Adding to the Basic Search Form

As mentioned you can customize your search form to search any specific field you have configured for use within your installation.

Below is an example of a custom search form that can pass some more basic elements that can be used to narrow your search:

<table width="100%" cellspacing="1" cellpadding="3" border="0">
<form action="index.php?a=19" method="get">
<tr>
<td><input type="text" name="b[search_text]"><!--text to search for-->
 
 
<!--category choice select box to allow search of several different categories or set to 0 to search all categories-->
<select name="c">
<option selected value="0">All Categories</option>
<option value="371">Announcements</option>
<option value="341">Antiques</option>
<option value="340">Automobiles</option>
<option value="381">Business</option>
<option value="342">Electronics</option>
<option value="344">Personals</option>
<option value="345">Real Estate</option>
<option value="382">Rentals</option>
</select>
 
 
 
 
<input type="hidden" name="b[search_descriptions]" value="1"><!--search listing descriptions-->
<input type="hidden" name="b[subcategories_also]" value="1"><!--search all categories below the one selected above-->
<input type="hidden" name="b[search_titles]" value="1"><!--search listing titles-->
<input type="submit" value="search"><!--button to submit the search-->
</td>
</tr>
</form>
</table>

There are other values that can be passed in and found through viewing the html source of the advanced search form produced by the script.

Important notes:

  1. ?a-19 is the link to the search function (see the form action below)
  2. The name of the input field searched must match the name of the field that is to be searched. Look at the "<input name=" value of the field to be searched within the advanced search form page to get the correct name of the element.
  3. The name of the select statement must equal c for using a dropdown category selection. You can use the select form to select a category as in the example below to search several individual categories or simply pass a "c" named value as a hidden form element value with a specific category id to search only one category. Please note any categories category id can be found in the categories admin tool of the geo admin tool. The category id for any category is the number in parentheses found next to every category name.
  4. Within the select tag are option tags. These are the categories of the dropdown. The values of the option tags must match the category ids of your category structure. ( Look in the admin for these category id numbers or simply hover your mouse over a category link within the client side and the category id is the b value). Value = 0 is for an All Category search.
  5. The hidden input tags tell what parts of the information of the ads to search.

You can do "range" searches only on number values of the site wide optional fields that have been configured to "# only" within the fields configuration tool here in the admin tool:

LISTING SETUP > FIELDS TO USE

For this example we will assume the use of site wide optional field #1.

You would be able to pass high and low limits to search by like so:

<input name="b[by_optional_1_lower]">
<input name="b[by_optional_1_higher]">

Replacing the Default Search Form With Your Own

Placing your search form does not replace the default search form generated by the software. If you are creating a form to replace the default generated one we recommend that you do not turn off the script generated one so it can be used as a reference. This switch to turn it off is here:

SITE SETUP > BROWSING SETTINGS > "Search Page Setup"

You will need to make sure your custom search page template has the {body_html} tag within it. If not the script will have no way to display the search results within that page. The above mentioned setting will turn off the display of the default advanced search form within the search form page leaving your own custom search form if you have properly set one up in the search page template. Also note the placement of the {body_html} tag within that template in reference to your search form. The search form and search results are the same page in the system and so use the same page template. The {body_html} tag must be in the page template so the system can place the search results in the page on the client side. If you want the search form to appear above the search results make sure your form appears before the {body_html} tag. If you want it after make sure your form appears after the {body_html} tag.

Once YOUR basic search form is working you can then start adding any optional site wide fields (if used over the whole site) to the search form. Follow how they are created within the script generated search form for the proper format. Only fields used across the whole site should be used within a search form that does not submit the category id of a specific category. If you create your own search form and assigned within the admin tool on the "search and search results" page of the pages management admin tool that is the form used for all searches. There will be no category specific settings appearing/disappearing according to the category choice in your site wide form as that capability is lost unless you code it back in. Again to see category specific search form for a specific category will require a search form created specifically for that category and set within the categories admin tool as a "search page" template for that category.

When your search form is working properly turn off the preconfigured search form switch to turn off the display of the script generated search form from the search page if you wish to use your own as default.

startup_tutorial_and_checklist/feature_configuration/search_configuration/custom_search_form.txt · Last modified: 2015/09/09 03:35 by pick_a_spot