How to get the popularity of a node ?

Author Message

Sébastien Antoniotti

Thursday 08 February 2007 8:07:27 am

Hi,

I'm looking for a solution to display how many times a node has been accessed (or viewed).

I have checked the attributes displayed by a {$node|attribute('show',3)} but I don't found anything that can help me.

Thanks in advance !

eZ Publish Freelance
web : http://www.webaxis.fr

André R.

Thursday 08 February 2007 10:11:45 am

http://ez.no/doc/ez_publish/technical_manual/3_8/features/cronjobs/the_cronjob_scripts#updateviewcount

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Sébastien Antoniotti

Thursday 08 February 2007 10:30:35 am

Hi,

thanks for your help, but I have already found this by this page : http://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/view_top_list

And I would like to do this without cron if possible...

eZ Publish Freelance
web : http://www.webaxis.fr

André R.

Thursday 08 February 2007 3:19:38 pm

Sorry for the short reply earlier, but you wont find anything looking thrue the node. Normally we use the cronjob I suggested or tings like Google analytics.

If both are out of the question you could make yourself an template operator that you call in the bottom of pagelayout outside any cache blocks.
The operator should then stores and retrive count number pr node, it should also sense if the page in question is a node or not (this can alternativly be done in the template).

Hope this help a bit more.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Sébastien Antoniotti

Thursday 08 February 2007 10:53:05 pm

Hi,

Thanks for all, I'm trying to enable the cronjob on my system, I'll use it.

Your second solution looks fine but I think it's better to use something already working.

Thanks again ;-)

eZ Publish Freelance
web : http://www.webaxis.fr

Sébastien Antoniotti

Friday 09 February 2007 12:57:01 am

Re-hi,

Running the cronjob.php (manually), I get this error :

Script cronjobs/updateviewcount.php starting

Warning: (PHP)
fopen( /var/log/apache2/domain/domain.dnsalias.net.access.log): failed to open stream: No such file or directory in /var/www/eztest/cronjobs/updateviewcount.php on line 101

Timing: ()
Script cronjobs/updateviewcount.php done

It's strange because /var/log/apache2/domain/domain.dnsalias.net.access.log exist and contain the access log of my website, moreover, everybody can read it...

The command that I use is

php runcronjobs.php  -d -s fr

I juste have one public siteaccess called "fr".

Did I forgot something ?

eZ Publish Freelance
web : http://www.webaxis.fr

Sébastien Antoniotti

Friday 09 February 2007 1:12:53 am

Sorry, there was a whitespace before the file name !

But now I get this :

Timing: ()
Script cronjobs/updateviewcount.php starting

Warning: (PHP)
Undefined offset:  1 in /var/www/eztest/cronjobs/updateviewcount.php on line 125

Warning: (PHP)
Undefined offset:  1 in /var/www/eztest/cronjobs/updateviewcount.php on line 118

Warning: (PHP)
Undefined offset:  1 in /var/www/eztest/cronjobs/updateviewcount.php on line 119

Warning: (PHP)
Undefined offset:  1 in /var/www/eztest/cronjobs/updateviewcount.php on line 123

Warning: (PHP)
Undefined offset:  1 in /var/www/eztest/cronjobs/updateviewcount.php on line 125

Timing: ()
Script cronjobs/updateviewcount.php done

and the view count attribute of my objects is still to 0.

eZ Publish Freelance
web : http://www.webaxis.fr

Kristof Coomans

Monday 12 February 2007 4:41:54 am

Hi Sébastien, are you using the SitePrefix[] setting in logfile.ini? At first sight (I'm trying it on a site here) the documentation seems to be wrong - or there's a bug in the script. You need to add an extra trailing slash (and you also need to escape this slash because it is going to be used in a regular expression) in the ini file:

SitePrefix[]=eng\/
SitePrefix[]=ezwebin_user\/

Does it work now?

I guess this is also what's going wrong reported in bug http://issues.ez.no/9559

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Sébastien Antoniotti

Monday 12 February 2007 6:05:10 am

Hi,

I have added this slash, but the view_count attributes are still to 0.

Since the begining, the ezview_counter table contains this :

mysql> select * from ezview_counter;
+-------+---------+
| count | node_id |
+-------+---------+
|    92 |      59 |
+-------+---------+

59 is a folder.

I think I have to write a template operator, who update a new specific table, everywhere I need to count and display the popularity of a node.

eZ Publish Freelance
web : http://www.webaxis.fr

Łukasz Serwatka

Monday 12 February 2007 7:14:56 am

Hi Sébastien,

Take a look on:
http://ez.no/community/contribs/template_plugins/ezviewcounter
http://ez.no/community/contribs/template_plugins/ezstats

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Sébastien Antoniotti

Monday 12 February 2007 7:38:09 am

Hi,

I think your extention is exactly what I need, thanks a lot, I will try it immediatly !

EDIT : it works like a charm !

eZ Publish Freelance
web : http://www.webaxis.fr

Sébastien Antoniotti

Monday 12 February 2007 8:59:59 am

It's me again...

I don't know why, but the view_count is too high for many nodes.

I have place this

{def $nbclics=ezviewcounter( $node.node_id, true())}

in the full view of my song class in order to update the count and display it, and this

{ezviewcounter( $node.node_id)}

in her line view in order to just display the number of clics.

And when I access a node who have the count at 0, I first view it by her line view, she says "0", so all is ok. Then I click on the line view (href), I come to the full view and the couner says me "1", so all is ok.
But when returning to the line view, (by viewing the parent node's full view of the song), the counter says me "2", or "3" (I have made this scenario many times, and the result is variant).

It seems that when I call

{ezviewcounter( $node.node_id)}

the counter is updated...

eZ Publish Freelance
web : http://www.webaxis.fr

H-Works Agency

Monday 02 March 2009 5:02:57 am

Hello,

I can't make this cronjob update my nodes view.

Is there a special format for the apache log file to be treated ?

In the php cron file it search for something like "/content/view/full" but in my log file it uses the node url_alias. Is this why it log my view count ?

Thanx

EZP is Great

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.