PassMark Logo
Home » Forum

Announcement

Collapse
No announcement yet.

Default search category

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Default search category

    I have two categories set up in our search engine, one for searching all .htm and .html documents, and another for searching for other documents (.doc, .pdf, etc), plus the default "ALL" category.

    We have a search box in our template so that the search engine is on all pages. When someone performs a search from there, by default, the search returns results from the "ALL" category.

    Is there a way to change the default category, so that when a user does a search from the search box (not the search.cgi page), it returns results of the "HTML documents" category I have set up rather than the "ALL" category?

    Thanks.

  • #2
    Yes. See the sub-section entitled "Defining a search form for a categories enabled website" under this FAQ:
    Q. How do I put search forms on pages besides the search page?

    In the example given in the FAQ, you can have a hidden zoom_cat[] variable which you can specify the value. If, for example, your "HTML documents" category has a category number of "0" ("-1" is always "All", and then the first category is "0", the second category is "1" and so forth), you would need the following in your search form HTML:

    Code:
    <input type="hidden" name="zoom_cat[]" value="0">
    --Ray
    Wrensoft Web Software
    Sydney, Australia
    Zoom Search Engine

    Comment


    • #3
      Similar question, but I'm using the ASP implementation with the search.asp form that you provide. Is there any way to configure that format to use a different default than "all" in the drop-down list?

      I actually have the exact same categories as mskarica, and I also want to display the "HTML Documents" category by default.

      I found the following bit of code in the search.asp file that seems to accommodate for marking an item as "selected" but I couldn't figure out how it does that:
      Code:
              	else
      	            Response.Write("<select name=""zoom_cat[]"">") & VbCrlf
      	            Response.Write("<option value=""-1"">" & STR_FORM_CATEGORY_ALL & "</option>")
      	            for zoomit = 0 to NumCats-1
      	                Response.Write("<option value=""" & zoomit & """")
      	                if (zoomit = zoomcat(0)) then
      	                    Response.Write(" selected=""selected""")
      	                end if
      	                Response.Write(">" & catnames(zoomit) & "</option>")

      Comment


      • #4
        We don't recommend changing the ASP script if you are not actually experienced with ASP scripting.

        You can pre-select options for the generated search form by adding parameters to the HTML link you use to get to the search page.

        For example, if your navigation menus currently contain a link to the Search page as "/search/search.asp", you can change this to "/search/search.asp?zoom_cat[]=0" assuming 0 is the category number for the category you wish to default to (see above post for explanation of category numbers). Similarly, you can preset other search options through this method.
        --Ray
        Wrensoft Web Software
        Sydney, Australia
        Zoom Search Engine

        Comment


        • #5
          Thank you, Ray. That worked perfectly.

          Is there a Help topic that lists all of the search options that can be called via a querystring variable like the example you showed for the category? I tried to search for it, but I didn't track one down.

          Comment


          • #6
            I don't think we have all the possible URL parameters documented in one place, however for most of them you can do some searches and examine the URL generated to get the parameters.

            Comment

            Working...
            X