The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 23 posts ] 
Author Message
PostPosted: Tue Nov 20, 2012 9:16 pm 
Joomla! Intern
Joomla! Intern

Joined: Sun May 02, 2010 9:50 pm
Posts: 61
Hello!

When i set cache option ON, on my joomla site, the article HITS stop counting at all.

How can i use cache properly but not affecting the counting function?

Thanks!


Top
 Profile  
 
PostPosted: Fri Nov 23, 2012 12:44 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Mar 30, 2009 9:43 pm
Posts: 45
Counting function is bad and doesn't give you proper information.
Use Google Analytic. It is about 98% right.

_________________
Web oglasi


Top
 Profile  
 
PostPosted: Fri Nov 23, 2012 8:46 am 
Joomla! Intern
Joomla! Intern

Joined: Sun May 02, 2010 9:50 pm
Posts: 61
That's kind of bad solution for this :)

Thanks anyway, i will wait for actual solution.


Top
 Profile  
 
PostPosted: Fri Nov 23, 2012 5:33 pm 
User avatar
Joomla! Champion
Joomla! Champion

Joined: Thu Aug 18, 2005 2:09 am
Posts: 5657
Location: California
vbarlakoski wrote:
When i set cache option ON, on my joomla site, the article HITS stop counting at all.
How can i use cache properly but not affecting the counting function?

EDITED

The full page cache affects anything which has regular updates.
Which is why the full page cache can often have limited usefulness.

.

_________________
██ AllMedia4Joomla Project
██ http://sourceforge.net/projects/allmedia4joomla/
██ AllMedia YöuTube Feed Gallery module released
██ Download: http://sourceforge.net/projects/allmedia4joomla/files/


Last edited by kenmcd on Fri Nov 23, 2012 6:29 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Fri Nov 23, 2012 5:55 pm 
Joomla! Intern
Joomla! Intern

Joined: Sun May 02, 2010 9:50 pm
Posts: 61
So, Conservative cache caches just display or full page cache, because when cache expires, hits are not updated at all!


Top
 Profile  
 
PostPosted: Fri Nov 23, 2012 6:32 pm 
User avatar
Joomla! Champion
Joomla! Champion

Joined: Thu Aug 18, 2005 2:09 am
Posts: 5657
Location: California
.
What I previously posted above was incorrect (so I edited it).

Hits are not counted in the background when the full page is cached.
Joomla counts hits when the page is built, and since it is not being built, no counting.

The best solution is to use external analytics as suggested above.

.

_________________
██ AllMedia4Joomla Project
██ http://sourceforge.net/projects/allmedia4joomla/
██ AllMedia YöuTube Feed Gallery module released
██ Download: http://sourceforge.net/projects/allmedia4joomla/files/


Top
 Profile  
 
PostPosted: Fri Nov 23, 2012 6:39 pm 
Joomla! Intern
Joomla! Intern

Joined: Sun May 02, 2010 9:50 pm
Posts: 61
I have found third-party plugin CacheControl, and i forbid option=com_content&view=article to cache, so, i have my hits back.

Joomla developers should really look into this thing.

Thanks for help!


Top
 Profile  
 
PostPosted: Fri Nov 23, 2012 7:34 pm 
User avatar
Joomla! Champion
Joomla! Champion

Joined: Thu Aug 18, 2005 2:09 am
Posts: 5657
Location: California
.
Then you have basically disabled caching for all content.
That makes no sense to me.
Just turn the cache plug-in Off instead.


.

_________________
██ AllMedia4Joomla Project
██ http://sourceforge.net/projects/allmedia4joomla/
██ AllMedia YöuTube Feed Gallery module released
██ Download: http://sourceforge.net/projects/allmedia4joomla/files/


Top
 Profile  
 
PostPosted: Fri Nov 23, 2012 7:39 pm 
Joomla! Intern
Joomla! Intern

Joined: Sun May 02, 2010 9:50 pm
Posts: 61
Its off for Article View from com_content, not for blog view, not for featured view, not for modules outside that view, not for other components. How this does not make sense?


Top
 Profile  
 
PostPosted: Mon Nov 26, 2012 1:11 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Jun 22, 2008 8:28 pm
Posts: 11
same problem

system: Joomla 2.5.8

if cache enabled article hits stopping. :((


Top
 Profile  
 
PostPosted: Mon Nov 26, 2012 5:58 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Tue Nov 29, 2011 2:43 pm
Posts: 525
Location: Bournemouth
To be honest, the hits counter within Joomla is pretty naff. Most opt to use external applications to monitor success of pages in a much detailed way than just 1 hit, 2 hits, and so on.

_________________
Affordable Web Design in Bournemouth
http://www.bybe.net


Top
 Profile  
 
PostPosted: Wed Dec 05, 2012 11:09 am 
Joomla! Intern
Joomla! Intern

Joined: Sun May 02, 2010 9:50 pm
Posts: 61
Is there any way in template_name/html/com_content/article/default.php to make connection with the database and increase the hits count? In that way, that query wont be cached i think or i'm wrong?

It seems wrong that cache stops hits counting, because there is ordering by hits option.


Top
 Profile  
 
PostPosted: Fri Feb 21, 2014 4:00 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Tue Apr 19, 2011 1:58 pm
Posts: 369
Location: Virginia Beach, Va
I know this is an older post, but I was able to come up with a solution for my website, increasing hits even if a cached page is being served. I posted the basic concept of the solution here: http://joomlacode.org/gf/project/joomla ... m_id=29831

It does involve a change to the core, but it works, and that's what I needed. If anyone has any questions as to how to get this working, just let me know.

_________________
Please let me know if I can help any further.
Thanks, BradM, with http://www.inmotionhosting.com Support


Top
 Profile  
 
PostPosted: Sat Mar 01, 2014 5:31 am 
Joomla! Ace
Joomla! Ace

Joined: Mon Nov 25, 2013 4:35 pm
Posts: 1291
Location: Montreal, Canada
Another way that doesn't involve modifying the core, is to create a system plugin that is run after the cache plugin runs, and that system plugin will update the page count. This'll work and it doesn't involve changing the core.

_________________
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter


Top
 Profile  
 
PostPosted: Sat Mar 01, 2014 11:26 am 
Joomla! Intern
Joomla! Intern

Joined: Sun May 02, 2010 9:50 pm
Posts: 61
There is a hack that works with Conservative and Progressive cache but not with System Cache.

In Site ROOT/index.php after $app->route(); insert this code:

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

 $db->query();
}


This will update hits in database in real time, but in article view will update every time when cache session expires with actual database hits.


Top
 Profile  
 
PostPosted: Mon Mar 03, 2014 5:22 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Tue Apr 19, 2011 1:58 pm
Posts: 369
Location: Virginia Beach, Va
Hi @itoctopus and @vbarlakoski,

Great ideas! Were you able to prevent Joomla from updating the hits two times in the event someone was not seeing a cached version of the page? IE, the code / plugins you described would update the hits, and then the normal Joomla code would run and update the hit again.

_________________
Please let me know if I can help any further.
Thanks, BradM, with http://www.inmotionhosting.com Support


Top
 Profile  
 
PostPosted: Mon Mar 03, 2014 5:25 pm 
Joomla! Intern
Joomla! Intern

Joined: Sun May 02, 2010 9:50 pm
Posts: 61
Joomla code will run once to activate new cache. So it will update hit once. I think its better to have one time double hit every time cache expires, than have no hits at all while cache is active.

But, this is temporary fix, it should not be permanent one if you need to edit the core.

I hope that Joomla will adapt the system to work properly with or without cache. Hits must be excluded from caching.


Top
 Profile  
 
PostPosted: Mon Apr 28, 2014 7:53 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Feb 14, 2014 8:59 am
Posts: 30
HI
everyone
i tried the solution by @vbarlakoski
but the problem is still there ,
As i tested it for joomla 3.2.2 the article hit counter call is different in both cases(joomla3.2.2 and joomla2.5.x)

in joomla 3.2.2 the article hit counter is increased by

Code:
   public function hit($pk = 0)
   {
      $input = JFactory::getApplication()->input;
      $hitcount = $input->getInt('hitcount', 1);

      if ($hitcount)
      {
         $pk = (!empty($pk)) ? $pk : (int) $this->getState('article.id');
         $db = $this->getDbo();

         $db->setQuery(

            'UPDATE #__content' .
               ' SET hits = hits + 1' .
               ' WHERE id = ' . (int) $pk
         );

         try
         {
            $db->execute();
         }
         catch (RuntimeException $e)
         {
            $this->setError($e->getMessage());
            return false;
         }
      }
      return true;
   }




this code


I tried it to add in the root/index.php file but its not working for me , may be the issue is incorrect implementation of the above code .
is there anyone who will help me to solve this known joomla bug?
Regards


Top
 Profile  
 
PostPosted: Mon Apr 28, 2014 8:02 am 
Joomla! Intern
Joomla! Intern

Joined: Sun May 02, 2010 9:50 pm
Posts: 61
I have done it this way:

I`m using jotCache for page caching.

Then i have created module that runs code for article hits increase.

Code:
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

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

?>


Then I have excluded the module from JotCache caching.

This works perfectly in 2.5.


Top
 Profile  
 
PostPosted: Mon Apr 28, 2014 8:14 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Feb 14, 2014 8:59 am
Posts: 30
HI @vbarlakoski
is it custom html module ??
any idea for joomla3.2.2?


Top
 Profile  
 
PostPosted: Mon Apr 28, 2014 8:19 am 
Joomla! Intern
Joomla! Intern

Joined: Sun May 02, 2010 9:50 pm
Posts: 61
You should try it.. Its custom module, that is changing the db values, so it should work in 3 too. Please share the result if you try it.


Top
 Profile  
 
PostPosted: Wed May 21, 2014 2:09 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu Nov 20, 2008 12:49 pm
Posts: 1
Does it also work with K2 Items?


Top
 Profile  
 
PostPosted: Sat Jun 28, 2014 4:11 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Feb 14, 2014 8:59 am
Posts: 30
Hi the issue is solved .


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ] 



Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group