I’m using modx 0.9.6 with friendly URLs and friendly URL paths turned on.
The module screen didnt work for me - images didnt load and javascript was broken.
Rather than fixing the javascript which would be too much for me(!) I ripped it out - here is the module code that loads the images and doesn’t display any javascript errors in the above conditions but doesn’t have the nice click on document to get statistics feature.
Could the author update it for modx 0.9.6 with friendly URLs and paths?
Thanks
// PageHitCounter - module for MODx 0.9.x
// creates page_hit_counter table if necessary
// displays page requests
// Version 2 - Ajax-based single page view
// 08-2006 [email protected]
// released to the Public Domain
// requires the CountPageHit plugin to insert data into the table
global $table_prefix, $manager_theme;
if(isset($_POST['tables']) && $_POST['tables'] == 'Create Table') {
$sql = "CREATE TABLE IF NOT EXISTS `".$table_prefix."page_hit_counter` (
`page_id` int(4) unsigned NOT NULL default '0',
`page_count` int(10) unsigned NOT NULL default '0',
UNIQUE KEY `page_id` (`page_id`)
)";
$modx->db->query($sql);
}
$basePath = $modx->config['site_url'];
$page = '
<html>
<head>
<title>PageHitCounter</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="' . $basePath . 'manager/media/style/'.$manager_theme.'/style.css?" />
<style>
#preLoader {
position: absolute;
z-index: 50000;
width: 100%;
height: 100%;
text-align: center;
vertical-align: middle;
}
.preLoaderText {
background-color: #ffffff;
width: 300px;
height: 150px;
padding: 50px;
border: 1px solid #003399;
}
</style>
<style>
.contextMenu {
background: #fff url(' . $basePath . 'manager/media/images/bg/context.gif) repeat-y top left;
margin: 0;
padding: 0;
border: 1px solid #003399;
border-left-color: #eaeaea;
border-top-color: #eaeaea;
border-right-color: #909090;
border-bottom-color: #707070;
position: absolute;
z-index: 10000; }
.cntxMnuItem {
background-image: url(media/images/_tx_.gif);
cursor: pointer;
color: #000;
padding: 3px 16px 3px 2px; }
.cntxMnuItemOver {
cursor: pointer;
color: #000;
background: #fc0 url(media/images/misc/buttonbar_gs.gif) repeat-x bottom left;
padding: 2px 15px 2px 1px;
border: 1px solid #fa0; /*#003399;*/
}
.cntxMnuItemDisabled {
cursor: default;
font: menu;
padding: 3px 16px 3px 2px;
color: #111;
}
.cntxMnuItem IMG, .cntxMnuItemOver IMG, .cntxMnuItemDisabled IMG {
margin-right: 8px;
}
.cntxMnuItem IMG, .cntxMnuItemDisabled IMG {
filter: gray();
}
.cntxMnuSeparator {
font-size: 0;
height: 1px;
background-color: #6A8CCB;
overflow: hidden;
margin: 3px 1px 3px 28px; }
.countTable{
width:300px;
margin-bottom:20px;
}
.countTable td{
padding-right:20px;
border-bottom:1px solid #000;
padding-top:10px;
}
.countTable th{
text-align:left;
border-bottom:1px solid #000;
}
</style>
</head>
<body>
<div class="subTitle">
<span class="right"><img src="' . $basePath . 'manager/media/images/_tx_.gif" width="1" height="5"><br />Page Hit Counter</span>
</div>
<div class="sectionHeader"><img src="' . $basePath . 'manager/media/style/'.$manager_theme.'/images/misc/dot.gif" alt="" /> Page Hit Counter</div><div class="sectionBody">
';
$sql = "SHOW TABLES LIKE '".$table_prefix."page_hit_counter'";
$rs = $modx->db->query($sql);
$count = $modx->db->getRecordCount($rs);
if($count < 1) {
$page .= '
<div class="searchbar">
<table border="0" style="width:100%">
<tr>
<td><form id="phcCreateTableForm" action="" enctype="multipart/form-data" method="post" style="margin:0;padding:0;" >
<fieldset style="border:none;margin:0 0 0 20px;padding:0;">
<label for="tables">Table does not exist. Please create the table: <input type="submit" name="tables" value="Create Table" /></label>
</fieldset>
</form></td>
<td nowrap="nowrap">
</td>
</tr>
</table>
</div>
';
} else {
$page .= '
<div id="mainContent"><div id="placeholder"></div>';
$sql = "SELECT * FROM ".$table_prefix."page_hit_counter";
$rs = $modx->db->query($sql);
$count = $modx->db->getRecordCount($rs);
if($count < 1) {
$page .= "No records found.";
} else {
// list page hits
$sql = "SELECT phc.page_count, sc.pagetitle FROM ".$table_prefix."page_hit_counter phc, ".$table_prefix."site_content sc WHERE sc.id = phc.page_id ORDER BY phc.page_count DESC, sc.pagetitle ASC";
$rs = $modx->db->query($sql);
$page .= '<table class="countTable" cellpadding="0" cellspacing="0" border="0"><tr><th>Page</th><th>Count</th></tr>';
while($row = $modx->db->getRow($rs)) {
$page .= '<tr><td style="width:80%">'.$row['pagetitle'].'</td><td>'.$row['page_count'].'</td></tr>';
}
$page .= '</table>';
}
$page .= '</div>
</div>
</body>
</html>
<!-- end footer -->
';
}
return $page;