home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / cfsearch.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  3.2 KB  |  93 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. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  12. <BODY  bgcolor="#FFFFD5">
  13.  
  14. <H3>CFSEARCH Example</H3>
  15. <P>The is a read-only example. Because accessing a collection is
  16. a sensitive area, consider the security of your collection
  17. prior to allowing any form of access to it. </P>
  18.  
  19. <!---
  20. <P>
  21. If you are not running a local CF Server, you will need to change
  22. localhost (in the URLPATH attribute) to your server name.  Additionally, 
  23. if the collection cannot be found, use the CFCOLLECTION
  24. example to create a collection named "Snippets".
  25. <HR>
  26. <P>To index the collection, select the check box
  27. on the form.
  28. <CFIF IsDefined("form.IndexCollection")>
  29. <!--- You may need to modify KEY to point to the snippets location. 
  30.       If you are not running a local CF Server, you will need to change
  31.       localhost (in the URLPATH attribute) to your server name --->
  32. <CFINDEX ACTION="UPDATE" COLLECTION="Snippets" 
  33.      KEY="#GetDirectoryFromPath(GetTemplatePath())#" TYPE="PATH" 
  34.      TITLE="Update Snippets Index" 
  35.      URLPATH="http://localhost/cfdocs/snippets/" EXTENSIONS=".cfm" RECURSE="Yes">
  36. <H3>Collection indexed</H3>
  37. </CFIF>
  38.  
  39. <CFIF IsDefined("form.source") AND
  40. IsDefined("form.type") AND IsDefined("form.searchstring")>
  41.  
  42. <!--- actually conduct the search --->
  43.     <CFSEARCH NAME="SearchSnippets"
  44.     COLLECTION="#form.source#"
  45.     TYPE="#form.type#"
  46.     CRITERIA="#form.searchstring#">
  47. <!--- print out the search results --->
  48.     <CFOUTPUT>
  49.     <H2>#form.type# Search Results</H2>
  50.     <P>#SearchSnippets.RecordCount# "hit<CFIF SearchSnippets.recordcount is not 1>s</CFIF>" found 
  51.     out of #SearchSnippets.RecordsSearched# total record<CFIF SearchSnippets.recordcount is not 1>s</CFIF>
  52.     searched.
  53.     <P><I><B>#form.maxrows# records returned ...</B></I>
  54.     <CFTABLE QUERY="SearchSnippets" MAXROWS="#maxrows#" STARTROW="1" COLHEADERS HTMLTABLE>
  55.         <CFCOL HEADER="SCORE" TEXT="#score#">
  56.         <CFCOL HEADER="TITLE" TEXT="<a href='#url#' target='blank'>#title#</A>">        
  57.         <CFCOL HEADER="SUMMARY" TEXT="#summary#">
  58.     </CFTABLE>    
  59.     </CFOUTPUT>
  60. </CFIF>
  61.  
  62. <!--- form to initiate the search --->
  63. <FORM ACTION="cfsearch.cfm" METHOD="POST">
  64. <H3>Simple Search Form</H3>
  65.  
  66. <P>Collection to Search
  67. <BR><INPUT TYPE="Text" NAME="source" VALUE="Snippets">
  68. <P>Type of Search
  69. <BR><SELECT NAME="type">
  70.     <OPTION value="Simple" SELECTED>Simple Search
  71.     <OPTION value="Explicit">Explicit Search
  72. </SELECT>
  73.  
  74. <P>Criteria for Search
  75. <BR><FONT SIZE="-1">(empty string will return all documents; try "CFINDEX" for your search)</FONT>
  76. <BR><INPUT TYPE="Text" NAME="SearchString" VALUE="">
  77.  
  78. <P>Maximum number of records to return:
  79. <BR><SELECT NAME="maxrows">
  80.     <OPTION VALUE="10" SELECTED>10
  81.        <OPTION VALUE="20">20
  82.        <OPTION VALUE="30">30
  83.     <OPTION VALUE="40">40
  84. </SELECT>
  85.  
  86. <P>Check box to index or reindex collection:
  87. <INPUT TYPE="Checkbox" NAME="IndexCollection">
  88. <P><INPUT TYPE="Submit" NAME="" VALUE="Index/Search Collection"> <INPUT TYPE="RESET">
  89. </FORM> --->
  90.  
  91. </BODY>
  92. </HTML>       
  93.