ababba2
-
Posts
34 -
Joined
-
Last visited
Posts posted by ababba2
-
-
Of course before removing the text inside the echo I tried this code too
<?php $db = JFactory::getDBO(); if(!$db) { echo "Unable to create DB reference"; } elseif(!$details->id) { echo "Details id does not exist."; } else { $query = "UPDATE __hdflv_upload SET times_viewed=1+times_viewed WHERE id={$details->id}"; $db->setQuery($query); if(!$db->query()) { echo "Error executing query. Follow Joomla documentation to output the error."; } else { echo "Success"; } } } ?>
With cache off, as result of the script I get "Success". And it's true.
With cache on, as result I get "success". But from Admin panel I see that isn't true.For caching... well. Browser caching is disabled. I don't mean that kind of cache.
I mean this kind of cache: https://docs.joomla.org/Cache
-
^Is working fine, but as I said there is cache problem.
I found this old quote on another forumt that could be useful
Problem is that Joomla counts and update the article hits when the page is built, but if the caching plugin is enabled and the page has been cached to disk, the page is loaded directly from the cache directory, without updating the number of views.
but still no solution
-
<?php $db = JFactory::getDBO(); if(!$db) { echo ""; } elseif(!$details->id) { echo ""; } else { $query = "UPDATE __hdflv_upload SET times_viewed=1+times_viewed WHERE id={$details->id}"; $db->setQuery($query); if(!$db->query()) { echo ""; } else { echo ""; } } ?>
This is working.
-
I used Psyco's script... I didn't changed anything in his script you see above... I just removed this
if(!isset($_SERVER['HTTP_CACHE_CONTROL'])) { echo "HTTP_CACHE_CONTROL doesn't exist"; } elseif($_SERVER['HTTP_CACHE_CONTROL'] != 'max-age=0') { echo "HTTP_CACHE_CONTROL doesn't equal 'max-age=0'. It is '{$_SERVER['HTTP_CACHE_CONTROL']}'."; } else {
Anyway, I'm getting this cache problem
-
Thank you, now the script works.
Anyway I'm facing another problem.
If I set the joomla cache of my site Off, then at every refresh I get +1.
Anyway, If I turn On the cache plugin, then I get +1 the first time I load the page and then it stop counting. I need to clear cache for get another +1 in the view count of that page.
From admin panel I see that every other page reload doesn't get count by the script.
How can I fix this?
I thought maybe I could disable caching for this little script. There are many plugin for this in Joomla, but I have no idea how to do this in php.
-
Sorry, it was my mistake
I don't have HTTP_CACHE_CONTROL
anyway I don't want to track unique IP/Views
I would like to have +1 views at every refresh/page open
-
I cannot use other tables...
I need to use __hdflv_upload and times_viewe for many reason...
-
Hi guys.
I need to make a view counting script for my site. Using mysql.
I tried with the following code. But I don't know why it doesn't work.
<?php $refreshed = $_SERVER['HTTP_CACHE_CONTROL']; if ($refreshed == 'max-age=0'){ $db = JFactory::getDBO(); $query = "UPDATE __hdflv_upload SET times_viewed=1+times_viewed WHERE id=" . $details->id; $db->setQuery($query); $db->query(); }?>
Using this code, views doesn't grow up.
And if possible, I would like to set +1 in the database at every refresh of the page.
Could someone give me help? Thank you
EDIT: of course __hdflv_upload already exist in the database
Count the number of times a page has been viewed
in PHP Coding Help
Posted · Edited by ababba2
Well, I don't think I will get any solution there.
Usually they don't offer this kind of support...
It's not the first time I ask them support for advanced problems and I never had answer...
Anyway I found this article on google: http://www.inmotionhosting.com/support/edu/joomla-3/increase-hits-cache
This explain how the fix view counter on articles when cache enabled. But my script is not based on article views. It's a different kind of view counter. But maybe could be useful for understand how to fix even my problem... They say to use jquery... do you think thi can be useful?