Member
Member
Ralf   2019-05-28, 16:41
#1
Hi,
is there a way to show the total amount of pageviews?

cheers
Ralf

Administrator
Administrator
acrylian   2019-05-28, 17:10
#2
Nothing except doing a db query to get all hitcounters.
Member
Member
Ralf   2019-05-30, 10:01
#3
Ok, thanks.
Administrator
Administrator
acrylian   2019-05-30, 10:06
#4
I just decided I will take a look if I can add something to the hitcounter plugin itself as that would probably be fitting. Something to choose what total hitcount you wish (all item types, only certain ones etc).

A access check is probably not really needed I guess although not visible/protected items would also be counted.

Member
Member
Ralf   2019-05-30, 12:22
#5
That would be great
Administrator
Administrator
acrylian   2019-05-30, 14:37
#6
@ralf It's already in the support build now.
Member
Member
Ralf   2019-06-20, 09:04
#7
Cool :-)
Member
Member
Ralf   2019-06-20, 09:40
#8
Hi Acrylian,
are there any usage informations?

Administrator
Administrator
acrylian   2019-06-20, 10:28
#9
As usual right within the code and the same here:
https://docs.zenphoto.org/1.5.3/function-getTotalHitcounter.html
It just returns the count, what you do with it is up to you.
Member
Member
Ralf   2019-06-20, 10:34
#10
Hi,
I have already had a look there.
But I can't get it working.
<?php
$h = getTotalHitcounter('albums', 'images', 'news', 'news_categories', 'pages');
if ($h == 1) {
echo "".gettext('1 view')."
";
} else {
echo "".sprintf(gettext('%u views'),$h)."
";
}
?>

Putting this code in an codeblock does not work.

Not working means:
There is no output and the footer will not be loaded.

It does well with the normal hitcounter:
<?php
$h = getHitcounter();
if ($h == 1) {
echo "".gettext('1 view')."
";
} else {
echo "".sprintf(gettext('%u views'),$h)."
";
}
?>

I took the code frome here:
https://forum.zenphoto.org/discussion/4812/hit-counter

It seems the problem is how the array is putted in:
$h = getTotalHitcounter('albums', 'images', 'news', 'news_categories', 'pages');

$h = getTotalHitcounter();

Will give a result of 0, which makes sense because the array is empty.
Already tried 'news' or news and also "news".


Would be great if you can give me a hint.
Administrator
Administrator
acrylian   2019-06-20, 10:45
#11
You need to pass an array of the tables you wish to get the hitcounts from. This ` getTotalHitcounter('albums', 'images', 'news', 'news_categories', 'pages')` is not an array!
Administrator
Administrator
fretzl   2019-06-20, 10:49
#12
```
getTotalHitcounter(array('albums', 'images', 'news', 'news_categories', 'pages'));```
Member
Member
Ralf   2019-06-20, 10:51
#13
@fretzl : Thanks a lot!
This one works!
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.