Reset Counters

12 posts by 4 authors in: Forums > CMS Builder
Last Post: August 2, 2011   (RSS)

Re: [videopixel] Reset Counters

I suppose this is a quite "exotic" question that i asked...

no answers?

[;)]

Re: [videopixel] Reset Counters

By Damon - October 10, 2009

Hi,

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.
Cheers,
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

Hi videopixel,

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.
All the best,
Chris

Re: [chris] Reset Counters

Damon, Chris,

Thanks for the tips... i will try the "IF" block for the increment...

Re: [Chris] Reset Counters

By videopixel - July 28, 2011

Hello Chris,

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

Bytheway another problem that I noticed:

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

Hi,

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

Ok here you go...

The blogdetail.php contains the "if with ip"

After the first page i see other blog entries but they are not ordered by "hits"...
Attachments:

blog.zip 7K

Re: [videopixel] Reset Counters

By Jason - July 30, 2011 - edited: August 2, 2011

Hi,

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/