##

## Creating Search Pages

PortWeb does not generate a search form. Instead, you have total freedom to create search requests in any format you can conceive of in HTML. This allows PortWeb to integrate seamlessly with your existing web site.

The search form you create can be as simple or as complex as your needs require. Two different commands provide for both simple and complex search queries: quickfind and query.

QuickFind Command

The quickfind command is a simplified search mechanism for basic keyword searches. It performs a “Keywords starts with” search with the specified text. The acceptable parameters are shown in the table below:

QuickFind Command
Parameter | Description
quickfind | This is the name of the command, but also the parameter for passing in the keyword to search for.
catalog | Specifies the alias of the catalog to be used. The alias is mapped via the settings file to either a catalog on disk or a catalog being served by a Portfolio server.
template [OPTIONAL] | Specifies the name of the Export HTML template to be used for the response page. If this parameter is not passed in, a default Export HTML template will be used (a basic thumbnail view layout in a 4 x 4 grid).
sorton [OPTIONAL] | Identifies the field on which to sort the found set is be sorted. The sort field must be an indexed single-value field. If it is not specified, the order of the record set is the order returned by the Find.
ascending [OPTIONAL] | Specifies the order in which the record set is sorted. A value of 0 indicates ascending, a value of 1 indicates descending. If the sorton parameter is not provided, this parameter is ignored. If the sorton parameter is provided and this parameter is not, the default sort order is 0 (ascending).
offset [OPTIONAL] | A positive integer indicating how many records have already been displayed from the collection. If the parameter is not specified, the display starts from the first record in the collection.

Examples:

- This simple search looks for the records containing a keyword that starts with “Com” in the catalog aliased to “Sample” in the PortWeb settings file. Records containing the keywords “computer” and “communications” would both be returned.

<A HREF="/scripts/PortWeb.dll?quickfind=com&catalog=Sample">...</A>

- This is essentially the same search, but using a form that allows the user to enter the keywords for which to search. This also shows all of the optional parameters being used.

<FORM ACTION="/scripts/PortWeb.dll?QuickFind" METHOD=POST > <INPUT NAME="quickfind" TYPE="Text" VALUE=""> <INPUT NAME="template" TYPE="HIDDEN" VALUE="Simple"> <INPUT NAME="sorton" TYPE="HIDDEN" VALUE="Filename"> <INPUT NAME="ascending" TYPE="HIDDEN" VALUE="1"> <INPUT NAME="offset" TYPE="HIDDEN" VALUE="10"> <INPUT NAME="catalog" TYPE="HIDDEN" VALUE="Sample"> <INPUT TYPE="submit"> </FORM>

Query Command

The query request is the core of PortWeb. This command causes a search to be performed in a particular Portfolio catalog, and the results to be returned in a particular layout. The values that can be passed in shown in the table below.

Query Command
Parameter | Description
query | This is the set of parameters that define the search.
catalog | Specifies the alias of the catalog to be used. The alias is mapped via the settings file to either a catalog on disk or a catalog being served by a Portfolio server.
template [OPTIONAL] | Specifies the name of the Export HTML template to be used for the response page. If this parameter is not passed in, a default Export HTML template is used (a basic thumbnail view layout in a 4 x 4 grid).
sorton [OPTIONAL] | Identifies an indexed, single-valued field on which the found set should be sorted. If it is not specified, the order of the record set is the order returned by the find.
ascending [OPTIONAL] | Specifies the order in which the record set is sorted. A value of 0 indicates ascending, a value of 1 indicates descending. If the sorton parameter is not provided, this parameter is ignored. If the sorton parameter is provided and this parameter is not, the default sort order is 0 (ascending).
offset [OPTIONAL] | A positive integer indicating how many records have already been displayed from the collection. If the parameter is not specified, the display starts from the first record in the collection.

Query Parameter

This parameter is a set of variables which define the search that should be executed in Portfolio. Each clause of a query is defined by three variables: Field, Operator, and Value. Each clause (after the first) must be joined to the previous using a join variable (either “and” or “or”).

The acceptable values for each variable are shown in the table below.

Query Parameter
Variable | Acceptable Values
field | Any indexed field in the specified database. If an unindexed field is specified, the query will fail.
op | The following operators are allowed*: Matches / Does Not Match – Works with all fields except Date fields Equals / Does Not Equal – Works only with Date fields Greater Than / Greater Than or Equal To – Works only with Number fields Less Than / Less Than or Equal To – Works only with Number fields Starts With / Does Not Start With – Works only with String fields
value | Only works with Number fields.
join [OPTIONAL] | Used only when the query has more than one clause, this can have a value of either “and” or “or”. If this parameter is not specified, “and” will be used.

* You can use all of the operators supported by the Portfolio client in PortWeb, however not all operators work with each field. If your operator does not work with a selected field, the search clause is skipped. If you're unsure whether an operator is supported with a specific field, you can verify it using the Portfolio client's find feature. Choose your fieldname in the Portfolio client's find dialog, then use the operator pull-down to see which operators are supported for that fieldname.

A query is validated by the plug-in based on the following criteria:

- All three variables must exist for each clause.

- For every clause after the first one, a join variable must also be supplied (with the value being either “and” or “or”).

- Each field variable and operator variable must meet the rules set above.

If any of these validations fails for a particular clause, the clause is skipped. If validation fails for all clauses in a query, the plug-in returns the “No matching records found” page. If the validation succeeds, the remaining parameters are evaluated.

A query can contain a maximum of ten clauses.

Example:

The following example shows a two clause query command. (The comments are just for clarity). The various parameters can be hidden or exposed, depending on the site’s needs. In this example, the first clause’s value field is entered by the user, but all other values are hidden.

<FORM ACTION="/scripts/PortWeb.dll?query" METHOD=POST > <INPUT NAME="template" TYPE="HIDDEN" VALUE="Simple"> <INPUT NAME="catalog" TYPE="HIDDEN" VALUE="Sample"> <!-- This is the first clause, and prompts the user for a keyword --> <INPUT NAME="field" TYPE="HIDDEN" VALUE="Keywords"> <INPUT NAME="op" TYPE="HIDDEN" VALUE="matches"> <INPUT NAME="value" TYPE="TEXT" VALUE=""> <!-- This is a second clause (with the required join) that is entirely hidden. --> <INPUT NAME="join" TYPE="HIDDEN" VALUE="and"> <INPUT NAME="field" TYPE="HIDDEN" VALUE="Extension Win"> <INPUT NAME="op" TYPE="HIDDEN" VALUE="matches"> <INPUT NAME="value" TYPE="HIDDEN" VALUE="jpg"> <INPUT TYPE="Submit"> </FORM>