<?php
// ViewCountPageHit - plugin for MODx 0.9.x
// maintains a count of page views
// 05-2008
// Documents set to not Log Visits will not be counted.
// requires PageHitCounter module
global $table_prefix;
global $modx;
// is the parameter ID set ?
$id = !is_null($id) ? $id : $modx->documentIdentifier;
// Get the Setting of 'donthit' for the Page with the ID: $id
$doc_donthit = $modx->getDocument( $id , 'donthit');
// Correct false counter
$add = 0;
if ($modx->documentIdentifier == $id) { $add = 1; }
// is the Page set 'donthit' ?
if($doc_donthit['donthit'] != 1 ) {
$output = $pre;
$rs = $modx->db->select(" * ", $table_prefix."page_hit_counter", '`page_id` = '.$id);
if($modx->db->getRecordCount($rs) == 1) {
while($row = $modx->db->getRow($rs)) {
$output .= $row['page_count']+$add;
}
}
else { $output .= $add; }
$output .= $past;
}
?>