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

  1. <!--- Search the Verity collection for our keyword(s) --->
  2.  
  3. <CFTRY>
  4.     
  5.     <CFSEARCH COLLECTION="cfexamples"
  6.         CRITERIA="#Form.Keyword#"
  7.         NAME="SearchResults"
  8.         TYPE="SIMPLE">
  9.     
  10.     <CFCATCH TYPE="any">
  11.     
  12.         <CFREGISTRY ACTION=GETALL
  13.             Branch="HKEY_LOCAL_MACHINE\SOFTWARE\Allaire\ColdFusion\CurrentVersion\Collections" 
  14.             Type="KEY"
  15.             Name="Collections">
  16.  
  17.         <CFSET CollectionFound = 'No'>
  18.  
  19.         <CFLOOP QUERY="Collections">
  20.     
  21.             <CFIF Collections.Entry IS 'cfexamples'>
  22.                 <CFSET CollectionFound = 'Yes'>
  23.             </CFIF>
  24.  
  25.         </CFLOOP>
  26.  
  27.         <CFIF CollectionFound IS 'No'>
  28.  
  29.         <!--- Create the collection --->
  30.  
  31.             <CFREGISTRY ACTION=GET
  32.                 Branch="HKEY_LOCAL_MACHINE\SOFTWARE\Allaire\ColdFusion\CurrentVersion\Collections"
  33.                 Entry="RootDirectory"
  34.                 Type="STRING"
  35.                 Variable="CFRootDir">
  36.  
  37.             <CFIF Server.OS.Name IS NOT "UNIX">
  38.                 <CFSET CollectionPath="#CFRootDir#\Verity\Collections\">
  39.             <CFELSE>
  40.                 <CFSET CollectionPath="#CFRootDir#/verity/collections/">
  41.             </CFIF>
  42.  
  43.                 <CFCOLLECTION Action="CREATE"     
  44.                     Collection="cfexamples" 
  45.                     Path="#CollectionPath#"
  46.                     Language="english">
  47.         </CFIF> 
  48.  
  49.  
  50.     <!--- This is the query whose data will be stored in the Verity index --->
  51.     <CFQUERY DATASOURCE="cfexamples" NAME="GetItems">
  52.         SELECT * FROM StoreItems, StoreManufacturers 
  53.         WHERE StoreManufacturers.ManufacturerID = StoreItems.ManufacturerID
  54.     </CFQUERY>
  55.  
  56.     <!--- This CFINDEX tag will actually perform the indexing of the query
  57.     data.  For each record, all the text in StoreManufacturers.Name,
  58.     StoreItems.ItemName, and StoreItems.ItemDesc will be indexed; when
  59.     a search is performed on this index, the ItemID and ItemName will
  60.     be returned as the Key and Title. --->
  61.  
  62.     <CFINDEX ACTION="UPDATE"
  63.         COLLECTION="cfexamples"
  64.         TYPE="CUSTOM"
  65.         BODY="ItemDesc,Name,ItemName"
  66.         KEY="ItemID"
  67.         CUSTOM1="Name"
  68.         CUSTOM2="ItemPrice"
  69.         TITLE="ItemName"
  70.         QUERY="GetItems">
  71.  
  72.     <CFSEARCH COLLECTION="cfexamples"
  73.         CRITERIA="#Form.Keyword#"
  74.         NAME="SearchResults"
  75.         TYPE="SIMPLE">
  76.         
  77.     </CFCATCH>
  78.     
  79. </CFTRY>
  80.  
  81. <!--- OK, start paying attention again... :^) --->
  82.  
  83. <!--- Check whether the index is properly built ---->
  84.  
  85.     <CFSEARCH 
  86.         NAME="CheckSearch" 
  87.         COLLECTION="cfexamples" 
  88.         CRITERIA = ""
  89.         MAXROWS = "1">
  90.         
  91. <!--- Now retrieve all the items from the store that
  92.     are part of the recordset CFSEARCH returned to us --->
  93.  
  94. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
  95.  
  96. <HTML>
  97. <HEAD>
  98.     <TITLE>Online Store - Search Results</TITLE>
  99. </HEAD>
  100.  
  101. <BODY BGCOLOR="#FFCC00" LINK="Maroon" BACKGROUND="images/storebg.gif" LEFTMARGIN=5 TOPMARGIN=0>
  102.  
  103. <CFINCLUDE TEMPLATE="_showcart.cfm">
  104.  
  105. <SPAN STYLE="position: absolute; left: 205px; top: 10px; width: 300px; z-index: 1">
  106.  
  107.     <!--- Show how many items we found --->
  108.     <P><FONT FACE="Helvetica"><B><CFOUTPUT>#SearchResults.RecordCount#</CFOUTPUT></B> item(s) found.</FONT></P>
  109.  
  110.     <BR><BR>
  111.  
  112.     <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="350">
  113.  
  114.     <!--- Now we'll just show the items that match the search,
  115.         if any; this code is taken straight from showitems.cfm. --->
  116.     <CFOUTPUT QUERY="SearchResults">
  117.     
  118.         <FORM ACTION="additem.cfm" METHOD="POST">
  119.  
  120.              <INPUT TYPE="HIDDEN" NAME="ItemID" VALUE="#Key#">
  121.  
  122.             <TR>
  123.                 <TD><FONT FACE="Helvetica" SIZE="-1" COLOR="##000000"><B>#Title#</B></FONT></TD>
  124.                 <TD ALIGN="RIGHT">
  125.                 <FONT FACE="Helvetica" SIZE="-1" COLOR="##000000">#DollarFormat(Custom2)#</FONT>
  126.                 </TD>
  127.             </TR>
  128.  
  129.             <TR>
  130.                 <TD COLSPAN="2">
  131.                     <FONT FACE="Helvetica" SIZE="-1">#Summary#<BR><BR>
  132.                     <B>Manufacturer: </B>#Custom1#<BR>
  133. <!---                     <B>Part Number:</B> #PartNum#</FONT> --->
  134.                 </TD>
  135.             </TR>
  136.  
  137.             <TR>
  138.                 <TD COLSPAN="2" ALIGN="RIGHT"><FONT FACE="Helvetica" SIZE="-1">
  139.                 <INPUT TYPE="SUBMIT" VALUE="Add to Cart"></FONT></TD>
  140.             </TR>
  141.  
  142.             <TR>
  143.                 <TD COLSPAN="2" HEIGHT="50"></TD>
  144.             </TR>
  145.  
  146.         </FORM>
  147.     
  148.     </CFOUTPUT>
  149.  
  150.     </TABLE>
  151. </SPAN>
  152.  
  153. </BODY>
  154. </HTML>
  155.