Hello MODX community,
i did some research in the forum but can't find a answer related to my problem:
I tried to integrate a simple page counter (hit counter) using a numeric TV and a snippet call in the template that increases that TV. Here is my snippet code:
<?php
$pagecount = $modx->resource->getTVValue('PageCounter');
$pagecount = intval($pagecount);
//if tv empty yet or not numeric, set zo zero;
if($pagecount == '' OR !is_numeric($pagecount)){$pagecount = 0;};
//increase count
$pagecount++;
//set tv
if (!$modx->resource->setTVValue('PageCounter', $pagecount)) {
$modx->log(xPDO::LOG_LEVEL_ERROR, 'The page count could not be updated!');
}
//return count
return $pagecount;
In the template (where the numeric TV 'PageCounter' is assigned to) i placed this snippet call [[!CountPageview]] (thats the snippet you see above). As is understand, the exclamation mark should cause the snippet call to be uncached, but the TV is only updated once after every cache clear. Is this a bug or i am doing wrong? I found a similar issue on Github (
https://github.com/modxcms/revolution/issues/8360) but there this problem is claimed as solved. I am running the latest version of Revo (2.2.14).
If you have any suggestions whats the problem and how i can resolve ist, i would really much appreciate it!
BTW: I am new to MODX and this is my first post on this forum – so let me say that i really love MODX and the great resources out there. Lovely!
André
[ed. note: digitalbricks last edited this post 12 years, 3 months ago.]