Custom Search Page
I was looking at the documentation for using a custom search form to search on the web. The 9.0.1 documentation can be found here: https://www.ibm.com/support/knowledgecenter/en/SSVRGU_9.0.1/basic/H_CUSTOMIZING_SEARCH_FORMS_7304.html I noticed a few things very importatnt when looking at this. The most glaring error is that it mentions a "search.h" file found in "Domino\Icons" for the default search form. In actuality, the form is "search.htm" and is found in "Domino\Template". I believe the rest of the documentation is correct, though.
To make your own custom search form, create a form called $$Search. This form will show up when the user wants to search a particular view (<database>/<view name>/$SearchForm?SearchView). I put a field called SaveOptions that is a text field computed to a value of "0". That prevents any back-end hacking from creating documents using this form. The other hidden field you will need is Path_Info. This is a computed for display field with a value of Path_Info. This is a CGI variable that gives the full path to the page that was opened. This will allow us to compute the name of the view the user wants to search.
There will be pass through HTML for the form tag. Close the Domino-generated form and open up a custom one. Part of the form is computed:
</form><form method="post" action="/<Computed Value>/<Computed Value>?SearchView">
The first Computed Value is @WebDbName. The second Computed Value computes the view name. It is much more complicated:
LowerPath := @LowerCase(Path_Info);
LowerDb := @LowerCase(@WebDbName);
NumCharsToKeep := @Length(@Right(LowerPath; LowerDb));
ViewNamePlusExtra := @Right(Path_Info; NumCharsToKeep-1);
@Left(ViewNamePlusExtra; "/")
The formula computes the view name used to open up this search form. It's basically everything between the slash after the database name (@WebDbName) and the next slash. This could be the UNID of the view, it could be "0" for the default view, or it could be the view name or alias. Any of those should correctly display.
From that point, you include the fields you want based on the documentation. Query is the one field that you need to have - an editable text field. The rest of the fields are optional:
- SearchOrder. A radio button field to indicate the sorting of results with options 1 (relevance), 2 (first modified), 3 (last modified), or 4 (keep current order).
- SearchMax. Indicates the maximum number of results to return. A value of "0" indicates to return all results.
- SearchWV. A value of "1" or "TRUE" indicates to use word variants ("cat" will also find "cats").
- SearchFuzzy. A value of "1" or "TRUE" indicates to use a fuzzy search.
<input type="Submit" value="Search"><-- -->
This will end up being the default form used when you search a view from the web.