Quote:
By making the $db_popular_cutoff = 1 (which it then modifies itself to 2) does that mean any site that gets at least 2 hits a day from you will get classed as popular?
Yes, that is the case. Of course, you don't need to set $db_popular_cutoff to 1. You can set it to a higher number, say 10.
Quote:
I did it like that and had 140 popular sites and a page with way too many links on it.
That is probably because a lot of those sites had a modification done which makes the date of the link more current than it would have been otherwise, or there are a lot of popular sites, or the cutoff is too low. Read on for more about this.
Quote:
($cutoff = $popular[$db_popular_cutoff - 1]);
From my limited programming knowledge, I presume that's referring to the an array called popular.. and element number cutoff-1 (being that the first one is 0 etc) is the record that the cut off point falls upon...
Yes, there is an @popular array built just before the section you are speaking of. It is arranged by number of hits, in descending order, I believe. $db_popular_cutoff-1 marks the point in the array where the cutoff is determined. The "-1" is used because the array is zero-based, so the 10th element is element 9 in reality (the first element being element 0).
So, if $db_popular_cutoff is set to 10, all links that have at least the number of hits specified in the 9th element of @popular are considered popular. The way the unmodified code was written, this should be the 10 resources with the most hits.
Applying the "average hits per day" mod to the $cutoff calculation changes everything. Setting $db_popular_cutoff to 10 with that mod does not necessarily mean that only the top 10 links will be listed. In this case, it means that a link must have at least an average of 10 hits per day to be considered popular. By adjusting that number up or down, you can decrease or increase the number of links displayed on the Cool page. You just need to find the setting you can live with, and then use it.
As the age of the links increases, the average number of hits per day decreases (unless they really do get that many hits per day on average) up until the point where the modified date of the link changes to a more recent date. When that happens, the average hits per day for that link will jump dramatically. For example, if a link 2 years old had 2000 hits, the average hits per day is 3 (2.7 rounded up). If the modified date changes to today's date, guess what? The average hits per day just changed to 2000 for that link and it is going to appear in the Cool page. In 7 days, assuming no more hits on the link, it will still have 286 hits on average per day, and 67 hits on average per day after a month has elapsed.
That's why I mentioned the 'DateAdded' field I added to links.def/links.db. It contains an unchangeable date that represents the date the record was added and is used to calculate the link's age, instead of the modified date. Using it, you get a truer average hits for day for each link no matter how many times the link has been modified.
One more point before I finish. If you change over to the "average hits per day" then there is no real way of listing just the top 15 as the mod is currently written. To do that would require further modification, maybe just grab the first 15 links in the @popular array and set "isPopular" to "Yes" for those links, and all other links to "No". I am not sure if that would work or not.
I hope I have made things a bit clearer to you and that some of this helps.
[This message has been edited by Bobsie (edited May 19, 1999).]