Adding Page Titles to Analog Reports From A Custom MySQL CMS

© copyright 18.Mar.2009 by Paul Bradley filed under MySQL


[Ad] need a break from coding?

Hoseasons Villas

Like most people I use Google Analytics to get statistics about my sites visitors, but I also use Analog to analyse my server log files. Analog was the first piece of software I used to analyse my sites traffic over nine years ago, and it's kind of hard to break the habit of using it, as it's so flexible and configurable. I configure it to give me a quick summary of the last three days worth of activity.

The articles on this site are held within a MySQL database; I basically have an articles table which has an auto incrementing id column, which becomes the URL for the article, with the help of a little Apache Mod Rewriting, and a title column, which naturally holds the title of the article.

Adding Page Titles Using FileAlias

Analog has a command which allows you to substitute the URL with the page title in it's reports. The syntax for the file alias command is :-

FILEALIAS /URL/ "Page Title"

SQL To Extract The Page Titles From The Database

The sample SQL below, is what I use to extract the ID number and Title from the database, and format it into a sequence of Analog FileAlias commands.

SELECT CONCAT(CONCAT(CONCAT(CONCAT(CONCAT(
  "FILEALIAS /", id),
   "/")),
   " ""),
   title, """)
FROM articles;

I run this SQL statement from a PHP script, via a cron job nightly, to append these commands to my main Analog configuration file, so that I always have page titles within my reports.

 


If you have found this article helpful or useful please consider linking to it, emailing it to friends, or share it with others using social sites like del.icio.us, Stumble Upon or Twitter.

Paul Bradley

About the Author
Paul Bradley is a VB.NET software developer living and working in Cumbria. He provides PHP & MySQL bespoke development services via his software development company, Carlisle Software Limited.
He has over 20 years programming experience.

Other Popular Articles

Categories & Topics

Home · Apache · JavaScript · Perl · PDF · PHP · MySQL · MSSQL · TAR · Ubuntu Linux · Video · Visual Basic

Browse the complete article history, and if you like what you see; consider subscribing to the rss feed.