User Guide

Table Of Contents
Enhancing search results 571
To retrieve information about the categories contained in a collection, you use the cfcollection
tag, and create an application page that retrieves category information from the collection and
displays the number of documents contained by each category. This example lets the user enter
and submit the name of the collection via a form, and then uses the
categoryList action to
retrieve information about the number of documents contained by the collection, and the
hierarchical tree structure into which the category is organized.
<html>
<head>
<title>Category information</title>
</head>
<body>
<cfoutput>
<form action="#CGI.SCRIPT_NAME#" method="POST">
Enter Collection Name: <input Type="text" Name="collection"
value="#collection#"><br>
<input Type="submit" Value="GetInfo">
</form>
</cfoutput>
<cfif isdefined("Form.collection")>
<cfoutput>
Getting collection info...
<br>
<cfflush>
<cfcollection
action="categorylist"
collection="#collection#"
name="out">
<br>
<cfset categories=out.categories>
<cfset tree=out.categorytrees>
<cfset klist=StructKeyList(categories)>
<table border=1>
<th>Category</th> <th>Documents</th>
<cfloop index="x" list="#klist#">
<tr>
<td>#x#</td> <td align="center">#categories[x]#</td>
</tr>
</cfloop>
</table>
<cfset klist=StructKeyList(tree)>
<table border=1>
<th>Category</th> <th>Documents</th>
<cfloop index="x" list="#klist#">
<tr>
<td>#x#</td> <td align="center">#tree[x]#</td>
</tr>
</cfloop>
</table>
</cfoutput>
</cfif>
</body>