Page View Counter

Page View Counter mod by Mika

(version 0.1, tested in 1.5.31)

1. database change

- add the following line in your phpmyadmin SQL view and run it
- it will create a new numeric column named views with zero as a default value
--standard mysql query
ALTER TABLE `articles` ADD `views` INT( 11 ) NOT NULL DEFAULT '0';
--mysql query using table PREFIX_
ALTER TABLE `PREFIX_articles` ADD `views` INT( 11 ) NOT NULL DEFAULT '0';

2. language variable (snews.php)

- add it somewhere in your language variables section
- it will be used inside article's infoline
$l['views'] = 'Views';

3. function tags() (snews.php)

- edit function tags() by adding a new element views in the array
function tags($tag) {
$tags = array();
$tags['infoline'] = '



4. function center() (snews.php)

- around line 512 find this snippet and add the blue part
if ($infoline == true) {
foreach ($tag as $tag) {
switch (true) {
case ($tag == 'date'): echo $a_date_format; break;
case ($tag == 'views'): echo ' '.$r['views'].' '.l('views').' '; break;

5. function center() (snews.php)

- a couple of lines below find this snippet and add the blue part
- this will increment view counter every time visitor hits full article view
- when logged in, view counter is disabled (otherwise all admin views/edits would be counted as well, but that would make the counter even less precise*)
else if (substr($position, 0, 1) != '2' && empty($currentPage)) {

if ($_SESSION[db('website').'Logged_In'] != token()) { $views = $r['views']; $views++; $queryUpdate = "UPDATE ".db('prefix')."articles SET views = $views WHERE id = $r[id]"; mysql_query($queryUpdate); }

19.02.2007. 17:13


sNews requires PHP, MySQL and mod rewrite. If your server meets those requirements, get started and learn how to install sNews on your website in 3 easy steps.


Browse through our help center and learn about template tags and how to simply create your own theme. Dig into sNews and customize it to behave the way you want.


sNews can be a simple blog tool and a full blown CMS. Customize it with addons, mods or play with different themes.


Talk about sNews on our Forum and share your expirience.