
BillG
User
May 30, 2003, 10:58 AM
Post #3 of 4
(3531 views)
Shortcut
|
|
Re: [woodwater] Hit Counter for Individual Articles?
[In reply to]
|
Can't Post
|
|
I don't know how to do it in CGI, but in Active Server Pages you can use the PageCounter component. Create a file called counter.asp, in a subdirectory ASPScript, with the following code: <% 'Instantiate the PageCounter object in IIS5 ' In IIS4 you may have to use IISSample instead of MSWC Set MyPageCounter = Server.CreateObject("MSWC.PageCounter") 'Increment the counter for this page. MyPageCounter.PageHit thisPage = Request.ServerVariables("URL") If Server.HTMLEncode(Request.QueryString("clear")) = "321" Then 'Reset the counter for this page, and reload MyPageCounter.Reset(thisPage) Response.Redirect(thisPage) End If Response.Write("<DIV class=PageCount>This Page has been viewed " & MyPageCounter.Hits & " times</div>") %> Then, add the following to your AM Article template: <!--#Include virtual="ASPScript/counter.asp"--> The cool thing about this is that you can reset any article's counter to zero by adding ?clear=321 to the end of any article URL. Of course, this assumes that you are using ASP pages and that your article's pages all end in .asp .
|