« Stop Press | Main | Friday Five »
November 28, 2003
MT Plugin: MostVisited
Yahoo! After a lot of fiddling I solved the problems with MT-MostVisited and also got it to integrate with awstats. First, I installed the plugin via the excellent plugin manager.
This did not work at all and even after I read the instructions (who reads them before you start?) and installed the Apache::Parselog, it still didn't work.
[Aside: That reminds me about the boy with a wooden whistle - it wooden (wouldn't) whistle. He got a steel whistle and it steel (still) wouldn't whistle. Then he got a tin whistle, now he tin (can) whistle.]
The error message was along the lines of:
Rebuild error: Build error in template 'Main Index': Error intag: You used an 'MTEntryLink' tag outside of the context of an entry; perhaps you mistakenly placed it outside of an 'MTEntries' container?
First attempt: wrap an MTEntry round the MTMostVisited tags. Didn't work BUT it did basically return the last 10 entries with nothing in the entry count field. Almost as if it didn't understand the MTMostVisited tags. Of course if it had rebuilt then I could have looked at the source of the index.html page and checked it but in fact the index rebuild failed (for multiple reasons).
Hmmm. Looking at the doc, it appears that the plugin is supposed to be in the MT/plugins directory but I could have sworn it was in the MT directory (alongside mt.cgi and similar files). Yup. OK, lets try moving mt-mostvisited.pl and apachelog.pl into the plugins directory.
Now there is still an error about log files:
Apache::ParseLog::getTransferLog: /var/log/httpd/access_log.1 does not exist. Exiting at /Library/WebServer/MovableType/plugins/apachelog.pl line 43
and I can get a similar message from the other file as well! So I did a bit of hacking in both files and added the awstats archive file (in my case this is in /var/spool/awstats/awstats_archive.something_or_other.log) and commented out dot 1 through to dot 6. The code now looks like:
@searchfiles = ("$awstat/awstats_archive.something_or_other.log",
"$logdir/access_log",
# "$logdir/access_log.1",
# "$logdir/access_log.2",
# "$logdir/access_log.3",
# "$logdir/access_log.4",
# "$logdir/access_log.5",
# "$logdir/access_log.6",
);
and of course the value of $awstat
is defined earlier.
That solved everything - check out the lovely new "Popular Entries" section on the right. It is not perfect - in particular it will fail to assess entries that are no longer in the log (i.e. when the log gets truncated) and it is hard coded for a particular blog (and I have multiple blogs here). I may look at caching the hit counts on the entries in mysql and simply tagging the date of the most recent check. That would mean that the most popular entry state could be obtained from the mysql database.
Posted by Ozguru at November 28, 2003 09:11 PM
Comments
Posted by: Ozguru at November 28, 2003 09:11 PM
Posted by: Eric James Stone at November 28, 2003 09:11 PM
Posted by: Procrastination at November 28, 2003 09:11 PM
Posted by: Procrastination at November 28, 2003 09:11 PM
Posted by: Procrastination at November 28, 2003 09:11 PM