Viewing 15 replies - 1 through 15 (of 16 total)
  • Hi DigitalAlias,

    the plugin works by adding 1 to the view count in the database when the_content() is called on a single page ( is_single() ). All I can think of right now is that the_content() is called more than once, somehow, on your page.

    Could you post your single.php on http://pastebin.com/ or some service like that so I could have a look.

    I’ll just do a bit more research into adding filters on the_content as well.

    I figured out the problem. If the_excerpt() is displayed on the page as well as the the_content() the code runs twice since they are both returning $content.

    I’ve just trying to figure out how to make it act only on full content…

    I’ve come up with a fix for this by offering an option on the settings page.

    Version 1.2 will be with you shortly. Just a bit more testing to do.

    Thread Starter DigitalAlias

    (@digitalalias)

    Very cool. Thanks for looking into this. In the “settings” page is there an option to reset the count – either by page or the entire site?

    There isn’t. I’ll add it to the “things to do” list.

    Perhaps have the reset post count on the post edit page itself, and a reset entire site in the setting page (with an “are you sure?” check)?

    I’ll have a think about it.

    Hi, Tom,
    I just downloaded and installed your plugin. The plugin is very nice, simple and consumes a little resources. It is exactly, what I need! πŸ™‚

    But I encountered the simple problem. The plugin don’t work with newest version of mySQL. In the ‘CREATE TABLE’ command you declare fields as ‘NOT NULL’, but function logCount don’t fill all corresponding fields. I correct this error by adding ‘DEFAUL 0’ to fields declaration.
    Can you correct this problem in official version of your plugin?

    Hi, once again…
    I’ve detected, that your plugin is gathering data for all posts, including deleted posts and revisions…

    I now, this is only theoretical problem. But I think, the option “Reset all counters”, by deleting all rows from hitcounter table, will be very usefull in this situation. πŸ™‚

    Hi TadeuszD, thanks for your feedback. You’re right about the DEFAULT 0 value. That’s easily sorted.

    Deleting view count: I’ve been thinking about this. If I have the reset button within the post edit page it needs to not refresh the page when clicked (and lose any changes you’ve made that havent saved) so I need to get my head around using AJAX in plugins. It doesn’t look too complex but I need to have a mess around with it.

    Regarding the ‘theoretical problem’. Are you saying that if you look at a deleted post, or a post revision, it counts as a view? I could do a check on post_status but it would require another database lookup.

    Hitcounter was never meant to be the be all and end all in viewing statistics. It was just to act as a guide as to the popularity of a post.
    Do you think it’s worth doing .1 release to add the DEFAULT status (you’re the first to mention it) or wait until I figure out the AJAX thing?

    Hi,
    About ‘theoretical problem’ – I wil check it again… I’ve tested many modification and it may be my fault. πŸ™ Please, don’t disturb yourself about this problem at this time.

    About ‘reset counters’ – The great advantage of your plugin is the siplicity. In my opinion using AJAX for reset counters is like “using the cannon to kill the mosquito” (this is the polish idiom).

    I’m thinking now… Reset counters option is only needed if we are generating many ‘false-views’ itself, while preparing and correcting posts. Instead of ‘reset’ option, you can add option which means “ignore users with security level greater than…”. This option will allow us to ignore our (admins or redactors) activity. What do you think about it?

    Thread Starter DigitalAlias

    (@digitalalias)

    Hi tomdebruin,

    I’m having a problem. The counter doesn’t seem to work anymore. Well; it doesn’t work when I check (enable) “Act on the_excerpt(); only” option. When I uncheck it, the counter works, but does doubles. When I check the option nothing is getting captured.

    http://www.fergytech.com

    Hi DigitalAlias, could you post your single.php code on http://pastebin.com/ or some service like that so I could have a look?

    I am too receiving double counts. If you could help me out I would greatly appreciate it! I have enabled the option for ignoring admin users, and when checking on a different computer, not logged into the site, I still receive double counts.

    http://pastebin.com/Ww1F8r97

    Hi blueboxed,

    I just used your code on a site and I’m just getting one count increment. Are you using the latest version of the plugin?

    Hmm thats odd. I just installed the plugin yesterday, so it’s up to date. The site is leakplay[] com. Im wasn’t sure if it had something to do with the excerpt being called or not, so I’ve tested the placement of the count code & it counts by two regardless of where I put the code (widget, footer, etc).

    Thanks for your quick response!

    @blueboxed, sorry for the delay in getting back to you, I’ve been away.

    Just had a look at your site, and had another look at the single.php code and it might possibly have something to do with line 42 – if (have_posts()) : while (have_posts()) : the_post(); ?>. Maybe the the_post is getting called again even if a valid post has been found – therefore counting for a second time.

    If you look at line 147 in hitcounter.php you’ll see add_filter('the_post', 'hc_detectAgent');. Experiment by changing the_post to the_excerpt or the_content (e.g. add_filter('the_content', 'hc_detectAgent');) and see if one of those options changes it for you.

    Alternatively take out the else statement in your single.php and create a 404.php file to handle errors.

    Let me know how it goes.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘[Plugin: hitcounter] Double Count’ is closed to new replies.