Server Time:
Thursday May 22 2008 04:05 PM  
Your Time:
  
HostMySite.Com is sponsoring this tutorial, please visit their site today!
This tutorial is sponsored by HostMySite.Com - ColdFusion Hosting

Dynamic Last Date Modified?
by: Pablo Varando
Email this tutorial to a friend Display Printer Friendly Format
[Download in PDF Format] [Download in FlashPaper Format]

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"
                   directory=
"#ExpandPath(".")#\"
                   name=
"qGetLastdateModified"
                   filter=
"#ListLast(CGI.SCRIPT_NAME, "/")#">

<cfif qGetLastdateModified.recordCount>
    <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">
  <cfdirectory action=
"list"
               directory=
"c:\directory_to_my_files\"
               filter=
"#page#"
               name=
"qGetFileDate">
  #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!

Questions? Comments? Please let me know by emailing me or by posting your questions on the EasyCFM forums!


Date added: Mon. April 12, 2004
Posted by: Pablo Varando | Views: 12953 | Tested Platforms: CF4,CF5,CFMX,BlueDragon | Difficulty: Beginner
Categories Listed: Other

HostMySite.Com is sponsoring this tutorial, please visit their site today!
This tutorial is sponsored by HostMySite.Com - ColdFusion Hosting

This author's other tutorials:
Delete files and folders in a specified path!
This tutorial will demonstrate how you can delete all files and sub-folders in a specified folder using ColdFusion and Windows! - Date added: Wed. September 7, 2005
Correct Content (document) serving!
This tutorial will demonstrate how to correctly serve documents via ColdFusion and allow you to correctly name the download as you see fit! - Date added: Tue. February 10, 2004
Creating your very own RSS XML Feeds with ColdFusion MX!
Have you ever wanted to create your very own RSS XML News Feeds? This tutorial will show you how to create an RSS feed that will allow you to syndicate your web site and allow the world to easily use your data! - Date added: Thu. January 15, 2004
Processing XML/RSS feeds with ColdFusion MX
This tutorial will show you how to parse XML files (RSS Feeds) with ColdFusion MX and it uses an EasyCFM.COM Feed for example [Feed: 5 Most Viewed Tutorials]. It shows you how to call it via CFHTTP all the way to parse and display your records! - Date added: Sat. December 27, 2003
Changing the form submission page on the fly!
This tutorial is not ColdFusion oriented, but covers a great trick to allow you to submit a single form to a variety of different pages on the fly. - Date added: Mon. December 1, 2003

Additional Tutorials:
· What is the ID for the record I just inserted?

· Creating a file content crawler with ColdFusion....

· Delete Records From Your Database With ColdFusion!

· Do you want to remember your members?

· Get A Folder Size Using ColdFusion and FSO...

· Preventing People From Leeching Your Images!

· Combining two queries into one..

· CaSe SensitiVe password logins!

· Creating an ODBC Connection within ColdFusion MX Server...

· Print your web pages on the fly!

· Using <CFPOP> and creating an email client for POP3 Email Reading!

· Using CFRegistry to Add Your IP To CF Debug IP List!

· Reading your IIS Log Files with ColdFusion!

· Automatically Adding Smiles To Your Messages!

· Using Arrays in ColdFusion To Properly Display Data....

· Implementing FORM Error Checking On Your Pages!

· Inserting FORM data into multiple database tables!

· Creating, Altering and Deleting database tables with ColdFusion.

· Sending multiple attachments with CFMAIL!

· ColdFusion and .INI Files!

· Clearing your session variables!

· Using PayPal's IPN with ColdFusion!

· Alternating Row Colors!

· Previous / Next n Records

· Using Query String Values....

· A quick intro into the world of Custom Tags!

· A brief demonstration of Fusebox 2.0

· Creating a Newsletter System....

· Count Active Users On Your Site.

· User Defined Functions....

· Creating a user athentication (Login) area.

· DSNLess Coldfusion?

· A Simple Contact Us Page….

· Having Your Database Do The Work… not ColdFusion!

· Retrieving Records From a Database..

· Inserting data into a database
Please rate this tutorial:
5 Stars 4 Stars 3 Stars 2 Stars 1 Stars
Comments on this tutorial
Read previous comments on this particular tutorial
Works great!
This is exactly what I was looking for! Thanks sooooooo much! -Dave
Posted by: David Pienta
Posted on: 04/14/2004 03:39 PM
You're welcome!
You're welcome, we're here to help you learn ColdFusion, Easily! :)
Posted by: Pablo Varando
Posted on: 05/06/2004 08:07 PM
Or..
..you simply insert this <!-- #BeginDate format:Ge1 -->03.11.2004<!-- #EndDate --> wherever you want to display the date when the page was last modified *cough*
Posted by: Matt
Posted on: 11/03/2004 10:01 AM
great stuff, but..
Hi, I stumbled across a cold fusion scrift on your page when looking to add a last modified function to a page.

My task is to find pages which havent been updated between certain time periods or in the last x amount of time.

To do this manually would be painstaking as the site in hand is already quite large, and will continuously grow over the coming year.
Can the second half of the script be modified to do this?

Posted by: Bam
Posted on: 01/28/2008 09:12 AM
Post a new comment on this tutorial
post a new comment on this particular tutorial
Your Name:
Your Email:
Comment Title:
Comments:
Key Phrase:
 
Skyscrapper Banner Advertisement
CF 8 Hosting for less then $40 a year!

You are 1 of 314 active sessions! | Privacy | Company
Copyright © 2002 EasyCFM.Com, LLC. (Easy ColdFusion Tutorials) All Rights Reserved (Server: www0002)
All other trademarks and copyrights are the property of their respective holders.
ColdFusion Hosting ColdFusion Hosting
ADD TO:
Blink
Del.icio.us
Digg
Furl
Google
Simpy
Spurl
Y! MyWeb