How to Display Number of Documents Returned by ?SearchView or ?SearchSite

Author: Tripp W Black

Created: 05/31/2001 at 11:48 AM

 

Category:
Notes Developer Tips
Forms/Subforms

Title: How to Display Number of Documents Returned by ?SearchView or ?SearchSite
Product Area: Domino Server
Product: Domino Server 5.x, Domino Server 4.6x, Domino Server 4.5x
Topic: Internet \\ Web Applications \\ Application Design
Number: 163256
Date: 01/04/2001



Problem:

When you use either $$SearchTemplateDefault or $$SearchSiteTemplates, you lose the "Number of Documents Found" functionality that is provided in the default SEARCH.HTM file. Can this functionality be achieved without having to write a LotusScript agent?

Solution:

Beginning with Domino 5.0, two reserved Notes fields are available for displaying the number of documents found. The following excerpt is from the R5 Designer Help, document "Customizing Search Forms":

Hits Actual number of results returned this page, may be less than Count requested. This field is useful in determining the Start parameter for a Next button.
TotalHits Total number of hits found by the search

The field TotalHits will return a total including documents that contain Readers fields which restrict the currently logged on web user from viewing the documents. The field Hits will not include Readers field restricted documents.

For versions prior to R5, this is possible using the JavaScript document property "document.links.length".

At the bottom of the design of the custom search results form, create a Computed for Display, Text field that contains the following formula:


"<script>document.write(document.links.length + \" Documents found.\") </script>"

Note: You will need to insert [ ] (square brackets) around this example formula just inside the first and last quotation marks. The brackets are omitted from the example above to prevent the formula from being rendered as pass through HTML when this document is viewed with a web browser.

In this formula, the JavaScript "document.links.length" property returns the total number of clickable links that are on the current HTML document above the script. For best results, place the field at the bottom of the search results form. If there are additional links on the document, modify the script to subtract their number from the total number of documents returned. For example, if there are 2 additional links on the $$SearchTemplateDefault that are provided in the design of the form for navigation or other purposes, use the following formula:

"<script>document.write(document.links.length-2 + \" Documents found.\") </script>"

previous page