load counter - how to?

Author Message

Marko Žmak

Sunday 13 March 2005 11:51:25 am

I want to count how many times a certain image was loaded and displayed. So I created a new class with an image and a counter. Each time an object of this class is displayed somewhere on my page I want to decrease it's counter.

How do I do that?

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

Hubert Farnsworth

Bård Farstad

Monday 14 March 2005 5:08:54 am

Marko,

eZ publish already has functionality to analyze the apache logfile to figure out how many times an article is viewed. This information can also be retrieved with an operator. More information about this can be found here:
http://www.ez.no/ez_publish/documentation/reference/data_fetching/content/view_top_list

For efficiency and due to view caching I recommend analyzing the apache logs. They contain the information and is already stored anyways.

--bård

Documentation: http://ez.no/doc

Marko Žmak

Saturday 19 March 2005 5:10:50 pm

> eZ publish already has functionality to analyze the apache logfile

How do I use this functionality?

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

Hubert Farnsworth

Łukasz Serwatka

Sunday 20 March 2005 11:38:17 pm

Hi Marko,

1. Configure settings/cronjob.ini
Add the following line:
Scripts[]=updateviewcount.php

2. Configure settings/logfile.ini
[AccessLogFileSettings]
#Where could find the apache log
#Example StorageDir=/var/log/httpd/
StorageDir=
#Example LogFileName=test.ezpublish.no
LogFileName=

Template example of fetch top 10 most popular articles in section 1 ( article class id is 2 )

{let view_list=fetch('content','view_top_list',hash(section_id,1,class_id,2,limit,10,offset,0))}
{section show=$view_list}
{section name=ViewList loop=$view_list sequence=array(bglight,bgdark)}
        <a href={concat("/content/view/full/",$ViewList:item.node_id)|ezurl}>
        {$ViewList:item.name}
        </a><br />
{/section}
{/section}
{/let}

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

Marko Žmak

Monday 21 March 2005 4:06:59 pm

Thanks for the help. I need only one thing more...

This template only shows the most popular articles, but how do I get the exact load count for an article from this. For example if I want to display on my page how many times an article was viewed?

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

Hubert Farnsworth

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

eZ debug

Timing: Jan 19 2025 09:53:45
Script start
Timing: Jan 19 2025 09:53:45
Module start 'layout'
Timing: Jan 19 2025 09:53:45
Module start 'content'
Timing: Jan 19 2025 09:53:46
Module end 'content'
Timing: Jan 19 2025 09:53:46
Script end

Main resources:

Total runtime1.0530 sec
Peak memory usage4,096.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 589.1484152.6250
Module start 'layout' 0.00510.0029 741.773439.4297
Module start 'content' 0.00801.0436 781.2031619.2031
Module end 'content' 1.05160.0014 1,400.406316.1875
Script end 1.0530  1,416.5938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.2924160.0002
Check MTime0.00130.1189160.0001
Mysql Total
Database connection0.00080.072410.0008
Mysqli_queries0.981793.2248650.0151
Looping result0.00080.0733630.0000
Template Total1.023097.220.5115
Template load0.00180.173520.0009
Template processing1.021196.975420.5106
Template load and register function0.00010.009710.0001
states
state_id_array0.00090.086910.0009
state_identifier_array0.00100.092820.0005
Override
Cache load0.00150.1471360.0000
Sytem overhead
Fetch class attribute can translate value0.00060.057630.0002
Fetch class attribute name0.00120.115280.0002
XML
Image XML parsing0.00860.815030.0029
class_abstraction
Instantiating content class attribute0.00000.0020100.0000
General
dbfile0.00860.8150330.0003
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs