iEntry 10th Anniversary RSS Newsletter Advertising
Visit Twellow.com
Text: Decrease Font Size Increase Font Size | Print Print Article | Share: Delicious Digg StumbleUpon Post to Twitter Post to Facebook
CommentThursday, October 7, 2004

Dynamic Last Date Modified?

When did you last change a web page? Have you ever wanted to dynamically display the last date modified on a page for your site?

This tutorial will show you how to do this on each page and it will also show you how to display a list of many files in a single location...

Let's begin,

The first example will show you how to incorporate this into the page the visitor is calling.. so when your visitor is visiting the "index.cfm" page it will show the last date modified... etc..

The first thing you do is is to create your actual page... we'll use the page called "index.cfm" as an example..

<!--- index.cfm page begins --->

YOUR CODE WILL GO HERE

<!--- display the last date modified area --->
<cfdirectory action="list"
&nbsp&nbsp&nbsp&nbsp&nbsp directory="#ExpandPath(".")#\"
&nbsp&nbsp&nbsp&nbsp&nbsp name="qGetLastdateModified"
&nbsp&nbsp&nbsp&nbsp&nbsp filter="#ListLast(CGI.SCRIPT_NAME, "/")#">

<cfif qGetLastdateModified.recordCount>
&nbsp <cfoutput>This page was last modified on : #DateFormat(qGetLastdateModified.dateLastModified, "mm/dd/yyyy")# </cfoutput>
</cfif>

<!--- index.cfm page ends --->

What this does is basically call <CFDIRECTORY> to call the page being called and get the last date modified for that particular file.

The next example will allow you to set a variable that contains a list of files you want to report a last date modified for, let's begin:

<cfset fileList = "index.cfm,page2.cfm,page3.cfm">

<cfoutput>
<cfloop list="#fileList#" index="page">
&nbsp <cfdirectory action="list"
&nbsp&nbsp&nbsp directory="c:\directory_to_my_files\"
&nbsp&nbsp&nbsp filter="#page#"
&nbsp&nbsp&nbsp name="qGetFileDate">
&nbsp #page# was last modified on : #DateFormat(qGetFileDate.dateLastModified, "mm/dd/yyyy")#<BR>
</cfloop>
</cfoutput>

So now you will be able to alert your visitors on when was the last time you modified a web page!

EasyCFM.Com introduces at least three new tutorials each week, written by the webmaster (Pablo Varando) and also from individual people who post their own tutorials for visitors to learn from. For more information please visit: http://www.easycfm.com [EasyCFM is Hosted by Colony One On-Line - http://www.colony1.net]

News Tags: HTTP
About the author:
EasyCFM.Com introduces at least three new tutorials each week, written by the webmaster (Pablo Varando) and also from individual people who post their own tutorials for visitors to learn from. For more information please visit: http://www.easycfm.com [EasyCFM is Hosted by Colony One On-Line - http://www.colony1.net]

Publish A Comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
2 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
SEARCH












Subscribe to WebProNews


Send me relevant info