Popular Posts

I have added two different ways of looking at popular posts on the sidebar.

One looks at my webserver logs and selects the posts who individual entry archive pages have been visited the most in the past 3 days. (Extension to longer times is possible if I knew Perl. [UPDATE: Used a nasty solution to extend the time frame. It is 8 days right now, but I am thinking about a 30-day period.]) Thanks to Rambles In The Brambles for the Most Visited plugin.

The other ranks the posts based on the number of comments. I am using the hack by ScriptyGoddess for this purpose. After I implemented it, I found out I could use Brad Choate’s MTSQL plugin to do this better.

UPDATE II: I have made changes to the MostVisited plugin so that it works with the server logs we have at Dreamhost. The log files are named by date and all logs older than 2 days are gzipped. After my modifications, the plugin copies the gzipped files (we don’t have write permissions in the log folder), unzips, parses and then deletes the files to save space. This is important as my single-day log file of around 1MB is reduced to less than 100KB because of compression.

Published
Categorized as Internet

By Zack

Dad, gadget guy, bookworm, political animal, global nomad, cyclist, hiker, tennis player, photographer

7 comments

  1. The Most Visited plugin sounds cool but I have my posts in different directories based on category and it doesn’t seem like he’s come up with a new version. I may try the hack mentioned in the comments though.

    Listing the entries with the most comments can be fun. Mine tend to be my most controversial posts.

  2. i hacked a most-comments-post script myself last night using PHP & MySQL (i set all html files to run as PHP scripts). i think the web server stuff is interesting-but what’s the point? it just biases with search engine queries-and those people are almost never regular readers and nor do they usually become so.

  3. Al-Muhajabah: Some changes in the MostVisited plugin are also required because of the Dreamhost setup. They use dates in the access log filenames and also gzip access logs older than 3 days. Right now, I have a cron job running once a day to copy and unzip the files since I don’t have write access in the logs directory. I’ll probably come up with a better solution later. Let me know if you want more details on how I am doing it and also if you come up with a better solution.

    Razib: I agree that posts with more comments are more interesting. However, in my case, 5 of the top 10 in Most Visited and Most Comments are common. Plus, this is a good way to look at which posts people are reading and direct more readers to those posts. I have gained quite a few readers through search engines, so I think it is worthwhile even with the high turnover rates of search-engine visitors.

  4. Zack, I have been trying to implement the “most commented on” feature. How do you do it usint the MTSQL plugin? Did you figure it out finally?

  5. KO: Actually, I didn’t implement the MTSQL method. The SQL query you need is given here. I think you would need to use that with

    <MTSQL> or <MTSQLEntries>
  6. Zack – You mentioned that you made some changes to the MostVisited plugin handle the gzipping/etc. Could you email a copy of your version to me? That seems like good functionality to include in the next version. Thanks for trying it out, and I hope that it works well!

Comments are closed.