Reset Counters
12 posts by 4 authors in: Forums > CMS Builder
Last Post: August 2, 2011 (RSS)
By videopixel - October 9, 2009 - edited: October 9, 2009
I'm going live in a few weeks and during development those counters where going up afcourse ;-)
I want to start "clean"
EVEN BETTER: Is there any way to filter/ignore the 'hits' by visiting the page as admin? ip number? etc. or maybe a kind of preview in the back-end for admins or editors...
thanks!
Re: [videopixel] Reset Counters
no answers?
[;)]
Re: [videopixel] Reset Counters
By Damon - October 10, 2009
I haven't had a situation to use the incrementCounterField yet but, it seems to me that if you want reset the "Hits" field counter, deleting the "Hits" field from a section and then re-creating should reset it.
I haven't gone through all the steps to try this but it sounds like it should work. Of course before trying this, backup your database, and copy your schema files before deleting anything.
Damon Edis - interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Damon] Reset Counters
By Chris - October 11, 2009
I'd go with Damon's suggestion of deleting and recreating the field.
The easiest way to prevent your hits from being incremented when you visit the pages is to add an IF block around your increment code which checks the IP of the visitor:
<?php if ($_SERVER['REMOTE_ADDR'] != '127.0.0.1') { incrementCounterField('article', 'hits', $articleRecord['num']); } ?>
I hope this helps. Please let us know if you have any questions.
Chris
Re: [chris] Reset Counters
Thanks for the tips... i will try the "IF" block for the increment...
Re: [Chris] Reset Counters
By videopixel - July 28, 2011
Again the IF code for a certain IP works perfect... but I also want on that same page to show the "hits"
<?php echo $record['hits'] ?>
If I use that code the IF statement does not work anymore and my personal visits adds a hit.
How to prevent this?
Re: [videopixel] Reset Counters
By videopixel - July 29, 2011
When you go to http://www.dirkbeckers.be/blog.php
you will see at the right popular blogs, they are sorted on "hits" and are correct but when you go 1 page further in my blog they don't stay correct anymore...??
Re: [videopixel] Reset Counters
By Jason - July 29, 2011
Could you describe the problem you see when you look at records past the first page?
Also, could you please attach the .php files you're working on so we can see the code you're using?
Thanks,
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Reset Counters
By videopixel - July 29, 2011 - edited: July 29, 2011
The blogdetail.php contains the "if with ip"
After the first page i see other blog entries but they are not ordered by "hits"...
Re: [videopixel] Reset Counters
By Jason - July 30, 2011 - edited: August 2, 2011
For the problem with your pages and "popular blog" section, I think the issue is that they are both using "perPage". With the popular blog column, I'm assuming that you want to show the top 6 blogs with the most hits. However, when you click to another page for the main blogs, the popular blog section is being incremented as well.
If you only want to show the top 6 blogs, regardless of what page you are on, try this change:
list($popular_blogsRecords, $popular_blogsMetaData) = getRecords(array(
'tableName' => 'blog',
'limit' => '6',
'allowSearch' => '0',
'orderBy' => 'hits+0 DESC',
'where' => 'status ="1"',
));
As for the hit incrementing problem, do you mean this line:
<?php if ($_SERVER['REMOTE_ADDR'] != '84.196.69.50') { incrementCounterField('blog', 'hits', $blogRecord['num']); } ?>
is being executed even when your ip is 84.169.69.50? What is the value of $_SERVER['REMOTE_ADDR'] when you visit the page?
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/