-
☆ A M B ☆
- 3,112 Posts
Is this question still open?
I'm reading the new forum, so a little bit hick ups on using this.
Quote from: lx at Aug 15, 2011, 04:03 AM
Hello goldsky,
I've tryed to use Your snipped, but it (onece the webpage is opened) it increases the value, but when i click on the next page it decreases the value 
Do You know what can be the reason?
When you click the next page, the snippet doesn't care anymore about the other e2g's sessions on the same page, but it will take the $_GET parameter as its initial state.
So the session is reset. (what the hell was I thinking?)
Considering about your snippet, I believe it won't take much effort since the hit is based on the user visit per resource.
You don't have to manage anything else.
[ed. note: goldsky last edited this post 14 years, 11 months ago.]
Rico
Genius is one percent inspiration and ninety-nine percent perspiration.
Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!
www.virtudraft.com
Security, security, security! |
Indonesian MODx Forum |
MODx Revo's cheatsheets |
MODx Evo's cheatsheets
Author of
Easy 2 Gallery 1.4.x,
PHPTidy,
spieFeed,
FileDownload R,
Upload To Users CMP,
Inherit Template TV,
LexRating,
ExerPlan,
Lingua,
virtuNewsletter,
Grid Class Key,
SmartTag,
prevNext
Maintainter/contributor of
Babel
Because it's hard to follow all topics on the forum, PING ME ON TWITTER
@_goldsky if you need my help.
Hello goldsky,
Yeas, this question is still valid and reading Your answer I still don't know what to do with this plugin.
Could You please show me how this code should look like to make it work properly?
Thx
Lucas
-
☆ A M B ☆
- 3,112 Posts
it is impossible that the counter decreases when hitting another page.

or try this slight changes
<?php
switch ($modx->event->name) {
case 'OnWebPageInit':
break;
case 'OnWebPagePrerender':
$tv = $modx->getObject('modTemplateVar', array('name' => 'hits'));
if (!$tv || $tv->locked)
return;
$id = $modx->resource->id;
$count = $tv->getValue($id);
$count++;
$tv->setValue($id, $count);
$tv->save();
break;
default :
break;
}
return;
Rico
Genius is one percent inspiration and ninety-nine percent perspiration.
Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!
www.virtudraft.com
Security, security, security! |
Indonesian MODx Forum |
MODx Revo's cheatsheets |
MODx Evo's cheatsheets
Author of
Easy 2 Gallery 1.4.x,
PHPTidy,
spieFeed,
FileDownload R,
Upload To Users CMP,
Inherit Template TV,
LexRating,
ExerPlan,
Lingua,
virtuNewsletter,
Grid Class Key,
SmartTag,
prevNext
Maintainter/contributor of
Babel
Because it's hard to follow all topics on the forum, PING ME ON TWITTER
@_goldsky if you need my help.
Hi goldsky,
Thank You for sharing.
Actually Your snippets work well. Just can't figure out why when I click for the next time on the same resource it displays again the previous value ... may by this is just an caching issue.
Luke