home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / cfsearch.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  3.0 KB  |  86 lines

  1. <!--- This example shows how to utilize CFSEARCH 
  2. to search an existing, populated collection  --->
  3.  
  4. <!--- If the collection cannot be found, use the CFCOLLECTION
  5.       example to create a collection named "Snippets"  --->
  6. <HTML>
  7. <HEAD>
  8. <TITLE>CFSEARCH Example</TITLE>
  9. </HEAD>
  10.  
  11. <BODY bgcolor=silver>
  12. <H3>CFSEARCH Example</H3>
  13. <P>
  14. If you are not running a local CF Server, you will need to change
  15. localhost (in the URLPATH attribute) to your server name.  Additionally, 
  16. if the collection cannot be found, use the CFCOLLECTION
  17. example to create a collection named "Snippets".
  18. <HR>
  19. <P>To index the collection, select the check box
  20. on the form.
  21. <CFIF IsDefined("form.IndexCollection")>
  22. <!--- You may need to modify KEY to point to the snippets location. 
  23.       If you are not running a local CF Server, you will need to change
  24.       localhost (in the URLPATH attribute) to your server name --->
  25. <CFINDEX ACTION="UPDATE" COLLECTION="Snippets" 
  26.      KEY="#GetDirectoryFromPath(GetTemplatePath())#" TYPE="PATH" 
  27.      TITLE="Update Snippets Index" 
  28.      URLPATH="http://localhost/cfdocs/snippets/" EXTENSIONS=".cfm" RECURSE="Yes">
  29. <H3>Collection indexed</H3>
  30. </CFIF>
  31.  
  32. <CFIF IsDefined("form.source") AND
  33. IsDefined("form.type") AND IsDefined("form.searchstring")>
  34.  
  35. <!--- actually conduct the search --->
  36.     <CFSEARCH NAME="SearchSnippets"
  37.     COLLECTION="#form.source#"
  38.     TYPE="#form.type#"
  39.     CRITERIA="#form.searchstring#">
  40. <!--- print out the search results --->
  41.     <CFOUTPUT>
  42.     <H2>#form.type# Search Results</H2>
  43.     <P>#SearchSnippets.RecordCount# "hit<CFIF SearchSnippets.recordcount is not 1>s</CFIF>" found 
  44.     out of #SearchSnippets.RecordsSearched# total record<CFIF SearchSnippets.recordcount is not 1>s</CFIF>
  45.     searched.
  46.     <P><I><B>#form.maxrows# records returned ...</B></I>
  47.     <CFTABLE QUERY="SearchSnippets" MAXROWS="#maxrows#" STARTROW="1" COLHEADERS HTMLTABLE>
  48.         <CFCOL HEADER="SCORE" TEXT="#score#">
  49.         <CFCOL HEADER="TITLE" TEXT="<a href='#url#' target='blank'>#title#</A>">        
  50.         <CFCOL HEADER="SUMMARY" TEXT="#summary#">
  51.     </CFTABLE>    
  52.     </CFOUTPUT>
  53. </CFIF>
  54.  
  55. <!--- form to initiate the search --->
  56. <FORM ACTION="cfsearch.cfm" METHOD="POST">
  57. <H3>Simple Search Form</H3>
  58.  
  59. <P>Collection to Search
  60. <BR><INPUT TYPE="Text" NAME="source" VALUE="Snippets">
  61. <P>Type of Search
  62. <BR><SELECT NAME="type">
  63.     <OPTION value="Simple" SELECTED>Simple Search
  64.     <OPTION value="Explicit">Explicit Search
  65. </SELECT>
  66.  
  67. <P>Criteria for Search
  68. <BR><FONT SIZE="-1">(empty string will return all documents; try "CFINDEX" for your search)</FONT>
  69. <BR><INPUT TYPE="Text" NAME="SearchString" VALUE="">
  70.  
  71. <P>Maximum number of records to return:
  72. <BR><SELECT NAME="maxrows">
  73.     <OPTION VALUE="10" SELECTED>10
  74.        <OPTION VALUE="20">20
  75.        <OPTION VALUE="30">30
  76.     <OPTION VALUE="40">40
  77. </SELECT>
  78.  
  79. <P>Check box to index or reindex collection:
  80. <INPUT TYPE="Checkbox" NAME="IndexCollection">
  81. <P><INPUT TYPE="Submit" NAME="" VALUE="Index/Search Collection"> <INPUT TYPE="RESET">
  82. </FORM>
  83.  
  84. </BODY>
  85. </HTML>       
  86.