Adobe COLDFUSION 9 Manual page 501

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Accessing and Using Data
To retrieve information about the categories contained in a collection, you use the
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
action to retrieve information about the number of documents contained by the collection,
categoryList
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>
For more information on using the
in CFML Reference.
cfcollection
tag to create Verity collections with support for categories, see
cfcollection
Last updated 8/5/2010
tag, and create an
cfcollection
496

Advertisement

Table of Contents
loading

Table of Contents