-
☆ A M B ☆
- 326 Posts
I’m trying to use Page Hit Counter and Page Hit Counter Results to display a "Most Viewed Pages" sidebar on my site. It actually is working, but the problem is, the same page is showing up multiple times in the results.
In my template, I’m calling the chunk {{populararticles}}, which looks like this:
<h3>Most Viewed Pages</h3>
<ul>
[!PHCResults? &excludeIDs=`1,2,3,4` &limit=`6` &table_prefix=`modx_` &tpl=`populararticlesitem`!]
</ul>
The template chunk (populararticlesitem) looks like this:
<li><a href="[+phc.pageID+]">[+phc.title+]</a></li>
Any ideas? What’s confusing to me is the fact that it’s working, but not correctly.
Sounds like the PHC is recording multiple entries for each page id in the modx_page_hit_counter DB table.
My results snippet doesn’t check or care if there are multiple rows.
Perhaps you could check via PHPMyAdmin and confirm?
-
☆ A M B ☆
- 326 Posts
I’ll take a look. I’m not a database expert, but I’ll see what I can find. Is there anything specific I should be looking for?
-
☆ A M B ☆
- 2,475 Posts
Bunk -- where are page hits stored, anyway?
-
☆ A M B ☆
- 24,524 Posts
{prefix}page_hit_counter
I do try to use self-explanatory names
It uses ON DUPLICATE KEY to update the count instead of inserting a new record if the docID is the same; the page_id field is a unique key. Could this misbehave depending on the version of MySQL?
This is what it should look like, i.e no duplicate page_id values.
-
☆ A M B ☆
- 24,524 Posts
You have to install the module and run it, and it will tell you the table doesn’t exist; there’s a button to create the table.
-
☆ A M B ☆
- 326 Posts
Mine looks more like the attached image (lots of repeating page numbers). Again, not a MySQL expert -- how do I prevent this from happening? I am using PHP5. Could this be part of the problem? That it doesn’t work right with ON DUPLICATE KEY? Can this be fixed?
-
☆ A M B ☆
- 24,524 Posts
Check the table and make sure that the page_id is still set as a UNIQUE KEY.