Forums / Setup & design / How does work view_count ?

How does work view_count ?

Author Message

Pascal France

Tuesday 14 August 2007 12:29:11 pm

Hi,

I would like to display the number of time a node has been viewed using view_count.

After looking for in the ez.no's forums and documentation parts I did the following:

1°/ In my public siteaccess cronjob.ini.append.php file:

<?php /* #?ini charset="utf-8"?

[CronjobSettings]
Scripts[]=updateviewcount.php

*/ ?>

2°/ In my public siteaccess logfile.ini.append.php file:

<?php /* #?ini charset="utf-8"?

[AccessLogFileSettings]
StorageDir=/var/log/apache/
LogFileName=access.log
SitePrefix[]=luxpopuli
SitePrefix[]=luxpopuli_admin

*/ ?>

In this code I tried also to add an escaped slash at the end of the two last lines (according with this post: http://ez.no/community/forum/setup_design/how_to_get_the_popularity_of_a_node#msg119935)

3°/ In my article view template:

{$node.view_count}

4°/ I run the runcronjobs.php script:

php runcronjobs.php -c -d -s luxpopuli

Using siteaccess luxpopuli for cronjob
...
...
...
Running cronjobs/updateviewcount.php
Update content view count...
Started at Mardi 14 Août 2007 8:20:20 pm

Start line:
82.67.66.131 - - [14/Aug/2007:20:18:21 +0200] "GET /images/btn-bkgd.gif HTTP/1.1" 404 17165 "http://luxpopuli.fr/ez_publish__1/documentation_ez_publish/reference_reference/objects_objets/ezbinaryfile" "Opera/9.22 (X11; Linux i686; U; en)" "-"

Finished at Mardi 14 Août 2007 8:20:20 pm

View count have been updated!


########### DEBUG ##########
Notice: (eZMySQLDB::query(0.000 ms) query number per page:0)
SET NAMES 'utf8'
...
...
...
Timing: ()
Script cronjobs/updateviewcount.php starting

Timing: ()
Script cronjobs/updateviewcount.php done


Total script time: 1.4071 sec

5°/ I access some articles

6°/ I re-run runcronjobs.php... but the counters on the public pages stay set to 0

Another thing:

I can't fing a "view_count" field in any ezcotobjectxxxx tables. So, how does work the updateviewcount.php script ?

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Felipe Jaramillo

Tuesday 14 August 2007 3:28:38 pm

Hi Pascal!

It seems your config is correct.

I believe the view_count is a very simple implementation of the eZPersisanceObject and it stores it's data in the ezview_counter table.

Maybe you can check if the records are actually being updated. Also, checkout the cronjob file as it's structure is pretty simple on how it retrieves and updates the records.

My main issue with it is that the view_counts obviously favours the oldest items in your site. It would be great to extend this functionality to add stats of views today, this week, this month and this year in addition to general views.

Regards,

Felipe

Felipe Jaramillo
eZ Certified Extension Developer
http://www.aplyca.com | Bogotá, Colombia

Pascal France

Wednesday 15 August 2007 3:25:23 am

Hi Felipe,

My view_count table only contains these values:

count   node_id
   4           819

My questions are:

- why only this node ?
- why the count colum is not updated (after running the updateviewcount.php script) if I access the node_id 819 many times ?

For information, this is a typical reccord of my apache log:

15.11.130.178 - - [15/Aug/2007:11:48:26 +0200] "GET /images/btn-bkgd.gif HTTP/1.1" 404 17165 "http://www.luxpopuli.fr/ez_publish__1/configuration__1/apache_mod_deflate_et_mod_gzip" "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6" "-"

and this is the content of the var/plain_site/log/updateview.log file:

# Finished at Mercredi 15 Août 2007 12:14:59 pm
# Last updated entry:
82.67.66.131 - - [15/Aug/2007:12:10:45 +0200] "GET /images/btn-bkgd.gif HTTP/1.1" 404 17165 "http://luxpopuli.fr/ez_publish__1/trucs_astuces" "Opera/9.22 (X11; Linux i686; U; en)" "-"

Maybe there is something wrong or missing in my logfile.ini ?

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish