Tally List : mailing list management, archiving, and analysis
click for archive home
 
Archive of:
CF-Talk
Cold Fusion - Technical
 
home
24 hour view
quick stats
weekly updates
 
all tallylists
corporate solutions
archive your favorite
help / feedback


Search the Tallylist search by keyword:

About Cold Fusion :
product's home
product's list home
 
  Archived TallyList / CF-Talk: 
Subject: Re: Page Counter
Brendan Avery (25p/+2r)     Posted: Friday 16 Feb 2001
This post: 90 views, +0 rating

<!--- SIMPLECOUNTER.CFM (may be renamed to whatever you want) by brendan avery - ba@brendanavery.com - http://www.brendanavery.com

---- description a simple hit counter example. use only in the context of <cfmodule> or as a custom-tag.

---- requirements <CFFILE> must be enabled.

---- attributes "filename" - string - required - this is the filename to use for the counter data. this filename should be the name of the file. if the full path is not used, the file will be read/written in the directory of the base template. to have different counters for different pages, just use different filenames. examples usage:

<cf_simplecounter filename="mycounter.txt"> <cf_simplecounter filename="mycounter2.txt"> <cf_simplecounter filename="subdir\mycounter.txt"> <cf_simplecounter filename="C:\mysite\mycounter.txt"> <cf_simplecounter filename="#expandpath('mycounter.txt')#">

"result" - string - optional - this is the name of a variable to return which will have a value equal to the NEW number of hits in the counter, or, in the event of an error, the value 0. example usage:

<cf_simplecounter filename="C:\mysite\counter.txt" result="mynumber"> total hits: <cfoutput>#mynumber#</cfoutput>

---> <cfparam name="attributes.filename"> <cfparam name="attributes.result" default=""> <cfset attributes.filename=#ExpandPath(attributes.filename)#> <cftry> <cffile action="READ" file="#attributes.filename#" variable="currentvalue"> <cfset currentvalue=#Int(Trim(currentvalue))#> <cfcatch> <cfset currentvalue=0> </cfcatch> </cftry> <cfset currentvalue=#currentvalue#+1> <cftry> <cffile action="WRITE" file="#attributes.filename#" output="#currentvalue#" addnewline="No"> <cfcatch> <cfset currentvalue=0> </cfcatch> </cftry> <cfif attributes.result is not ""> <cfset "caller.#attributes.result#"=#currentvalue#> </cfif>


Similar Subject Line Posts (+/- two weeks of this post)
RE: Page Counter  17 Feb 2001   (43 v/ +0 r)
RE: Page Counter  16 Feb 2001   (57 v/ +0 r)
Re: Page Counter  16 Feb 2001 (this post)   (90 v/ +0 r)
Re[2]: Page Counter  16 Feb 2001   (93 v/ +0 r)
Page Counter  16 Feb 2001   (46 v/ +0 r)
 

Send a reply to the CF-Talk list!
click to send a reply! NOTE: Many lists will reject your post unless you have already registered with them. Also - don't forget the right account to send from (for those with multiple emails!)

Feedback: If this post was exceptionally helpful, please help by giving this post a positive review.

 

TallyList : copyright Ububik - 2000