Exponential Project Websites Statistics : Portals Now Offer Limited Preview of Page View Count at the Bottom of the Pages
I have been working on adding exponential.earth node view count tracking to the site/network of sites recently.
After some initial questions on why web server access log (ssl) page request logging data import into the very node template features desired for simple display in many ways throughout a website portal built using Exponential was not more popular in the past as hoped to end users to adopt the feature instead seeking a more powerful external solution, still for me it seems this feature has been very simple to work with.
First remember to configure your siteaccess settings file, settings/siteaccess/website/logfile.ini.append.php
Here is an example from our work:
<?php /* #?ini charset="utf-8"? # Exponential configuration file for logfile configuration for stats parsing. # Exponential configuration file for parse apache log file # [AccessLogFileSettings] # Storage of the log file, for example /var/log/httpd # Do not add trailing slash StorageDir=/usr/local/apache/domlogs/exponential/ # The name of log file, for example mytest.log LogFileName=ezpublish.se7enx.com-ssl_log # If using site match by URL, the site may like http://siteurl/mysite and # apache log will start with for example mysite/content/view/full/node_id. To # remove this prefix in apache log before analysis the log, add mysite to # SitePrefix. Example: SitePrefix[]=mysite # SitePrefix[]= # If any site accesses use the PathPrefix setting, enter them here PathPrefix[] PathPrefix[]=Exponential */ ?>
Then I had an issue that may have been affecting other users of PathPrefix setting in logfile.ini.append.php and site.ini.append.php the root / matched node 2 the root node and not /Exponential/ (a much larger nodeID) due to a multi site flaw in the cronjobs/updateviewcount.php. We are soon to publish a clean fix from 7x the company producing new versions with new improvements and updates of Exponential CMS in version 6.0.11 (coming soon).
Here is a diff:
diff -ri cronjobs/updateviewcount.php.default cronjobs/updateviewcount.php 7c7 < * @version //autogentag// --- > * @version 2014.07.0 19c19 < eZDB::instance()->setIsSQLOutputEnabled( false ); --- > eZDB::instance()->setIsSQLOutputEnabled( true ); 180,183c180,189 < $nodeID = eZURLAliasML::fetchNodeIDByPath( $path ); < < // Support for PathPrefix < for ( $pathPrefixIndex = 0; !$nodeID && $pathPrefixIndex < $pathPrefixesCount; ++$pathPrefixIndex ) --- > // Support for PathPrefix > if( $pathPrefixesCount >= 1 ) > { > for ( $pathPrefixIndex = 0; !$nodeID && $pathPrefixIndex < $pathPrefixesCount; ++$pathPrefixIndex ) > { > // Try prepending each of the existing pathPrefixes, to see if one of them matches an existing node > $nodeID = eZURLAliasML::fetchNodeIDByPath( $pathPrefixes[$pathPrefixIndex] . $path ); > } > } > else 185,186c191 < // Try prepending each of the existing pathPrefixes, to see if one of them matches an existing node < $nodeID = eZURLAliasML::fetchNodeIDByPath( $pathPrefixes[$pathPrefixIndex] . $path ); --- > $nodeID = eZURLAliasML::fetchNodeIDByPath( $path ); 208a214 > $cli->output( "Node ( " . $nodeID . " ) View count have increased: Count: $count \n" ); 215c221,222 < $counter->increase( $count ); --- > $cli->output( "Node ( " . $nodeID . " ) View count have increased: Count: $count \n" ); > $counter->increase( $count ); 235c242 < $cli->output( "View count have been updated!\n" ); --- > $cli->output( "View count have been updated.!\n" );
Here is the configured cronjob (part defined by ini settings/override/site.ini.append.php) example for update_view_count script:
<?php /* #?ini charset="utf-8"? # eZ Publish configuration file for cronjobs. # # # NOTE: It is not recommended to edit this files directly, instead # a file in override should be created for setting the # values that is required for your site. Either create # a file called settings/override/cronjob.ini.append or # settings/override/cronjob.ini.append.php for more security # in non-virtualhost modes (the .php file may already be present # and can be used for this purpose). [CronjobSettings] ScriptDirectories[]=cronjobs Scripts[]=unpublish.php Scripts[]=rssimport.php Scripts[]=indexcontent.php Scripts[]=hide.php # Since 4.6 the following script is not activated by default #Scripts[]=subtreeexpirycleanup.php Scripts[]=internal_drafts_cleanup.php #Scripts[]=unlock.php #Scripts[]=staticcache_cleanup.php Scripts[]=updateviewcount.php #Extension directory for cronjobs. ## ExtensionDirectories[] # No more than one instance of a cronjob script can be run at any given time. # If a script uses more time than MaxScriptExecutionTime, the next instance of # it will try to gracefully steal the cronjob script mutex. If the process has # been running for more than two times MaxScriptExecutionTime, the original # process will be killed. The default is 12 hours. MaxScriptExecutionTime can # also be set per cronjob part, that will override this global setting. MaxScriptExecutionTime=43200 [CronjobPart-infrequent] Scripts[]=basket_cleanup.php Scripts[]=linkcheck.php [CronjobPart-frequent] Scripts[]=notification.php Scripts[]=workflow.php [linkCheckSettings] # Specify full path of all site URL # Example: # SiteURL[]=http://ezpublish.ez.no/admin # SiteURL[]=http://ezpublish.ez.no/news SiteURL[]= [CronjobPart-unlock] Scripts[]=unlock.php [CronjobPart-cluster_maintenance] Scripts[]=clusterpurge.php # Example of a cronjob part # This one will only run the workflow cronjob script # #[CronjobPart-workflow] #Scripts[]=workflow.php [CronjobPart-index] Scripts[]=indexcontent.php [CronjobPart-view_count_update] Scripts[]=updateviewcount.php */ ?>
Then run the cronjob:
./runcronjobs.php -s exponential view_count_update;
Which outputs:
./runcronjobs.php -s exp view_count_update Using siteaccess exponential for cronjob Running cronjob part 'view_count_update' Running cronjobs/updateviewcount.php at: 09/09/2025 01:44 am Update content view count... Started at Tuesday September 09 2025 01:44:58 am Start line: 217.113.194.215 - - [09/Sep/2025:01:31:03 -0700] "GET /layout/set/print/content/keyword/Book HTTP/1.1" 200 6133 "-" "Mozilla/5.0 (compatible; Barkrowler/0.9; +https://babbar.tech/crawler)" Node ( 60005 ) View count have increased: Count: 8 Finished at Tuesday September 09 2025 01:44:58 am View count have been updated.! Completing cronjobs/updateviewcount.php at: 09/09/2025 01:44 am Elapsed time: 00:00:00
And with that the data has been collected and is available for display within Exponential Templates!
Views: <b>{$node.view_count}</b>
Happy Hacking in the Exponential Community and the Greater Exponential Ecosystem!
Comments