What's New CFC

The What's New Component for ColdFusion MX is designed to search you site directory and return a CF query object with the data you can use to display a "What's New" listing.

Read Me

1. Drop the cfc into you components path (or a sub-directory of you site)

2. Drop 'whats_new.cfm' into your website's root directory.

3. Open and edit whats_new.cfm

  • Change line 1 to the number of days back you want
  • Change line 2 to the physical path want to search for new documents.

4. Open your browser of choice and access the what's new cfm file

Note: Currently, the cfc only looks for files with the extenstions: .htm and .html In version 2, I will be expanding this and allowing it to be set in the cfm.

Screenshots

Click on the snapshot above to get a full screen view of my example script.

Example Source Code

<cfset days = "11">
<cfset thisDir = "c:\Program Files\Apache Group\Apache2\htdocs\whats_new_testing">
<html>
<head>
	<title>What's New Test</title>
</head>
<body>
<p align=center>CF_MX <strong>"What's New"</strong> Component test page</p>

<!--- For debugging purposes only. This stuff can be removed --->
<cfoutput>Searching #thisDir# for updates in the last #days# Days...<br></cfoutput>
<!--- End debugging info --->

<cfflush>
<cfinvoke component="components.whatsnew" returnvariable="fileList" method="recdir">
	<cfinvokeargument name="dirName" value="#thisDir#">
	<cfinvokeargument name="days" value="#days#">
</cfinvoke>
<cfif fileList.recordCount GT "0">
	<cfset records = #fileList.recordCount#>
	<cfoutput><p>There were #records# files updated in the last #days# days</p></cfoutput>
	<cfquery dbtype="query" name="updatedFiles">
	SELECT * FROM fileList ORDER BY modDate DESC
	</cfquery>

	<cfoutput query="updatedFiles" group="modDate">
		#DateFormat(modDate, "full")#
		<blockquote>
		<cfoutput group="uri">
			<a href="#updatedFiles.uri#">#updatedFiles.title#</a><br>
		</cfoutput>
		</blockquote>
	</cfoutput>
<cfelse>
	<cfoutput>There apparently were no files updated during the past #days# days</cfoutput>
</cfif>

<!--- For debugging purposes only. This stuff can be removed --->
<p><strong>Dump of file data:</strong></p>
<blockquote>
	<cfdump var="#fileList#">
</blockquote>
<!--- End debugging info --->
</body>
</html>

Buy this component at CFTagStore.com

Home | About | Contact | Customers | Services

Copyright © 2004, C.P. Web Designs