You can use form and action pages similar to the following examples to select and index a
collection.
To select which collection to index:
Create a ColdFusion page with the following content:
1
<html>
<head>
<title>Select the Collection to Index</title>
</head>
<body>
<h2>Specify the index you want to build</h2>
<form method="Post" action="collection_index_action.cfm">
<p>Enter the collection you want to index:
<input type="text" name="IndexColl" size="25" maxLength="35"></p>
<p>Enter the location of the files in the collection:
<input type="text" name="IndexDir" size="50" maxLength="100"></p>
<input type="submit" name="submit" value="Index">
</form>
</body>
</html>
Save the file as collection_index_form.cfm in the myapps directory under the web_root
2
Note: The form will not work until you write an action page for it, which is the next procedure.
To use cfindex to index a collection:
Create a ColdFusion page with the following content:
1
<html>
<head>
<title>Creating Index</title>
</head>
<body>
<h2>Indexing Complete</h2>
<cfindex collection="#Form.IndexColl#"
action="refresh"
extensions=".htm, .html, .xls, .txt, .mif, .doc"
key="#Form.IndexDir#"
type="path"
urlpath="#Form.IndexDir#"
recurse="Yes"
language="English">
<cfoutput>
The collection #Form.IndexColl# has been indexed.
</cfoutput>
</body>
</html>
Save the file as collection_index_action.cfm.
2
In the web browser, enter the following URL to display the form page:
3
http://127.0.0.1/myapps/collection_index_form.cfm
Creating a search tool for ColdFusion applications
.
521
Need help?
Do you have a question about the COLDFUSION MX 61-DEVELOPING COLDFUSION MX and is the answer not in the manual?
Questions and answers