Forums / Setup & design / ezview_counter

ezview_counter

Author Message

Marko Žmak

Sunday 27 March 2005 8:03:18 am

I got some answers about how to use apache logs for counting previews of pages in eZ. Bot noone told me how to use that data in eZ templates. There was mention about "ezview_counter" somewhere in the forums, but none told how it can be used.

Can anyone tell me how to use "ezview_counter"?

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Łukasz Serwatka

Tuesday 29 March 2005 12:23:49 am

Hi Marko,

The best way to use ezview_counter to display count for one node is to write your own template operator with one argument node_id for example.

More about custom operators here
http://ez.no/ez_publish/documentation/development/extensions/template_operator

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

Marko Žmak

Tuesday 29 March 2005 7:15:34 am

I'm a little bit short of time for writing opreators. Isn't there a ready made sollution for this? Somwhere inside eZ Publish or in the User Contributions.
From all the people that are using eZ, there must be someone who needed this before.

Another question. If a custom operator has to be made in order to use ezview_counter, what does updateviewcount.php script do? Where does it store data and why this data cannot be retreived without making custom operators?

Thx.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Łukasz Serwatka

Wednesday 30 March 2005 1:41:05 am

Script updateviewcount.php is using to parse Apache logs, and updates ezview_counter table. So ezview_counter table store info how many times specific node was viewed.

view_top_list fetches a list of most viewed node objects. You can fetch all and filter results for current node but this is lessefficient. Better is to write custom operator.

Something like:

showCount( $node ) {
    $count = "SELECT count FROM ezview_counter WHERE node_id='" . (int)$node . "'"
    return $count;
}

Function with one argument ($node) and simple SQL query. This is example of course not ready operator and I hope it will point you in right dircetion.

http://ez.no/ez_publish/documentation/reference/data_fetching/content/view_top_list

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

Marko Žmak

Wednesday 30 March 2005 1:05:14 pm

Thanks, I'll try to make the best of it.

Are there any plans to make such an operator part of regular eZ installation? I supose there are lots of people that use eZ who would like something like this. I'm surprised no one have already created something similar.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Łukasz Serwatka

Thursday 31 March 2005 11:03:43 am

Marko, I contributed ezviewcounter operator.
http://ez.no/community/contribs/template_plugins/ezviewcounter

Any suggestions are very welcome.

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

Marko Žmak

Thursday 31 March 2005 2:36:06 pm

Thx. I already found another sollutio, but I'll check out your too and report my experience.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Łukasz Serwatka

Thursday 31 March 2005 9:10:09 pm

Great, what solution did you find? This is interesting.

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

Marko Žmak

Friday 01 April 2005 2:54:32 am

Actually it's not my sollution... I was contacted by Konrad Mazurkiewicz <[email protected]>. He has read my posts on the forum about counters and told me that he has an extension oh his own.

So he sent me his extension with an operator gostats() that goes included in pagelayout.tpl and inserts statistcs data in his database table (lr_stats). He also sent me the definition of the table. His sollutin was interesting because this operator can be inserted anywhere in the page, and can store data about node_id, section_id, username, IP adress...
Then I sent him some suggestions and code for template operator gostas_count() which retreives the count for desired node_id. He inserted this code in this extension and it works O.K. I'm gonna try it today.
This sollution is what I really need, because I can manually call gostat() for every node that I want, so I can even count how many times a node was fetched from the database, and many other things.

If there are more people interested in this, maybe I'll ask Konrad if he is willing to develop it together with me. If we make something useful for wider audience, we could contribute it to eZ.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Eivind Marienborg

Friday 01 April 2005 4:43:23 am

Hi,

I'm very interested in an extension like this. I can't find it in the contribs, though.. Anyone care to direct me to the correct place?

Marko Žmak

Friday 01 April 2005 2:26:00 pm

You could contact Konrad about it. His mail is in the post above.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Konrad Mazurkiewicz

Friday 01 April 2005 3:52:23 pm

Hi,

I made some changes in extension today and if Marko agree with that it will be contributed.

Marko Žmak

Tuesday 05 April 2005 5:05:39 pm

We agreed and here is the contribution:

http://www.ez.no/community/contribs/template_plugins/ezstats

Hope serves somebody. We would also aprecciate some feedback.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Eivind Marienborg

Wednesday 06 April 2005 1:37:48 am

This looks great! Thanks for a great extension. It seems to work fine on 3.4.0 too, in addition to the two versions mentioned in the docs.

Marko Žmak

Wednesday 06 April 2005 4:18:32 pm

I'm glad it serves someone. It's mostly Konrad idea, I contriubted some suggestions, and also suggested to put it in the contributions. But now tha we're on it I hope we'll develop it even more. So any suggestions are welcome. The first things in the TODO list are:

- implementing operator ezstats_set_count() for manually setting an resseting counters
- implementing something like counter IDs, so that nodes can be counted in different ways (e.g. how many times a node was displayed in different parts of the web page)

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Eivind Marienborg

Wednesday 06 April 2005 11:16:18 pm

These are mostly minor things, but still:

- Viewing traffic for smaller periods than one month (e.g. one day, one hour, one week, etc)
- Viewing traffic for each section (lots of pages won't show up in the top 100, but it would still be nice to see how many times they've been viewed)
- Adding links to the top 100 list, to make the items in the list clickable

Marko Žmak

Thursday 07 April 2005 8:19:35 am

We could make template operators (or more probably extend the ezstats_get_count() operator) so that counts for different criterium (section_id, user_id, date_from, date_to...) can be fetched. The you'll be able to create your own templates for showing statistics. Is that good enough?

Thx for the suggestions, I'll add this in the TODO list:

- extend ezstats_get_count() to use more parameters

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

Eivind Marienborg

Thursday 07 April 2005 8:58:25 am

Sounds great :)

Eivind Marienborg

Friday 15 April 2005 11:51:49 pm

It would also be nice to be able to select a user and a starting time, and then get displayed what pages that user has viewed.

This would be handy in regards to seeing where users move on your site, what links they click etc., to see how the users actually use your site.

Marko Žmak

Saturday 16 April 2005 5:15:46 am

Yep all this is and much more is planned, unfortunaltely we're a little bit short of time do deal with it. I'll try to make some new things in a few weeks, hope a new more usable version will come put in the May.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth