Keyword

Hits counter when using Jotcache

  • dennisb
  • dennisb's Avatar Topic Author
  • Offline
  • New Member
More
9 years 10 months ago #128581 by dennisb
Hits counter when using Jotcache was created by dennisb
Hi,

I'm looking for a solution to use full page caching (jotcache), but still counting and display the total hits.

When I activate the jotcache full page caching, the number of hits will only count up once in a while when the page cache is expired and have to be recached.

for normal Joomla! articles, I found a good solution, described in the topic below:

Joomla forum hits counter with full page cache

Is there a way to implement this solution for K2 items?

Please Log in or Create an account to join the conversation.

More
9 years 10 months ago #128582 by Lefteris
Replied by Lefteris on topic Re: Hits counter when using Jotcache
Hi. Yes if it works for Joomla! articles it can also work for K2 items. You just need to modify the query so it updates the K2 items table. In general, hits are there to provide a general image of the item popularity, not to provide accurate statistics. For such usage you are suggested to use a tool like Google Analytics.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • dennisb
  • dennisb's Avatar Topic Author
  • Offline
  • New Member
More
9 years 10 months ago #128583 by dennisb
Replied by dennisb on topic Re: Hits counter when using Jotcache
Ok, I will try to figure out how to modify the query for K2 items.

Yes I know that the amount of hits is to provide a general image of the item popularity, but it looks strange when a webpage has serveral thousands hits, a main article only showed up 62 hits.

I think there are more people with this problem, and looking for a solution.

Please Log in or Create an account to join the conversation.

More
9 years 10 months ago #128584 by Lefteris
Replied by Lefteris on topic Re: Hits counter when using Jotcache
According to the link you provided the code should be:
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

if (isset($_GET['view']) && strtolower($_GET['view']) == 'item') {
 $articleId = (int) $_GET['id'];
 
 $db = JFactory::getDBO();
 $db->setQuery(
                        'UPDATE #__k2_items' .
                        ' SET hits = hits + 1' .
                        ' WHERE id = '.(int) $articleId
                );
 $db->query();
}

?>

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • dennisb
  • dennisb's Avatar Topic Author
  • Offline
  • New Member
More
9 years 10 months ago #128585 by dennisb
Replied by dennisb on topic Re: Hits counter when using Jotcache
Thank you verry much!!!!

This worked for me!


I installed a custom code module.
insert this code and exclude this module position from being cached.

Now every time the k2 item page is recached, the new hits are displayed correct.

Please Log in or Create an account to join the conversation.

More
9 years 10 months ago #128586 by Lefteris
Replied by Lefteris on topic Re: Hits counter when using Jotcache
You are welcome.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
9 years 10 months ago #128587 by Marcos
Replied by Marcos on topic Re: Hits counter when using Jotcache
Hello! Would you be so kind as to share the module that has developed? Because my great ignorance did not allow me to implement it myself.
Thank you!

Please Log in or Create an account to join the conversation.

More
9 years 9 months ago #128588 by Petar
Replied by Petar on topic Re: Hits counter when using Jotcache
What module use for php code
I try Blank module and Flexi custum code, put code you write above, exclude position in Jotcache, But does not work
Please help

Please Log in or Create an account to join the conversation.

More
9 years 9 months ago #128589 by Lefteris
Replied by Lefteris on topic Re: Hits counter when using Jotcache
@Petar Grgurev

I cannot know why this does not work. I was just asked to provide some code. I don't even know how Jotcache works. K2 includes also a module for custom code. Try to use that.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
9 years 9 months ago #128590 by Petar
Replied by Petar on topic Re: Hits counter when using Jotcache
BIG BIG Thnx Lefteris Kavadas
I try with K2 tools custum code. Put this code in module, set module to desidered position, excluded this position from caching, but no result. Hit are not increased by +1
Is code good. I have latest K2 and latest joomla 3.3
Big Thnx

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum