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 / cfindex.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  3.2 KB  |  96 lines

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