Warning: The author of this contribution does not provide support for it anymore.

phpBB Statistics

Why not a "Total Views" - phpBB Statistics

Why not a "Total Views"

by Abera » Wed Jul 21, 2010 12:06 am

It looks like you worked alot on the MOD, but why not a "Total Views" on the index? When I was running andy2295 on the index it showed the Total Views (hits.. guests, or registered) to the site. Up until 3.0.7-PL1 came out. Since andy took off and didn't update his version, it didn't work anymore. No way to install due to the 3.0.7-PL1 structure that I know how to do. Is there any way you could do a little update to your MOD. Just in a little over a year my site had 1.5 million plus hits. Very impressive to me and the users.
Thanks

PS I still run this on my local and I have a copy of andy's if you want.

This is what it looked like:
Statistics
Total posts 3452 • Total topics 858 • Total ads: • Total members 612 • Views 1,573,322 • Our newest member zzz
Abera
Registered User
Posts: 674
Joined: Mon Jan 15, 2007 1:26 am
Contact:

Re: Why not a "Total Views"

by iftitaj » Wed Jul 21, 2010 3:24 am

Off-topic: Those hits include hits from bots too like search engine crawlers, etc. Sorry to say, those 1.5m hits must have majority portion of those bots.
iftitaj
Registered User
Posts: 638
Joined: Tue Jan 15, 2008 6:21 am
Location: Karachi, Pakistan
Contact:

Re: Why not a "Total Views"

by Abera » Wed Jul 21, 2010 4:31 am

What the users don't know won't hurt. Wink.. wink.
Abera
Registered User
Posts: 674
Joined: Mon Jan 15, 2007 1:26 am
Contact:

Re: Why not a "Total Views"

by Marc » Wed Jul 21, 2010 1:37 pm

Well, I can't change anything about it. I'm using the total views of phpBB3's database. If they count Bots, that is phpBB3's problem, not mine. :P

Anyhow, I've already done that once before, although that was for phpBB 3.0.6. Anyhow, it should work with 3.0.7-PL1:
marc1706 wrote:Subject: phpBB Statistics

stokerpiller wrote:Hello Marc,

I was wondering if you could make something for me.
I need total toicviews on my index page, can it be done?


Here you go:

Open index.php
Find:

Code: Select all

$total_users   = $config['num_users'];


After add:

Code: Select all

// Get total topic views -- START
$user->add_lang('mods/stats');
$sql = 'SELECT SUM(topic_views) AS count
      FROM ' . TOPICS_TABLE . '
      WHERE topic_approved = 1';
$result = $db->sql_query($sql);
$total_views = (int) $db->sql_fetchfield('count');
// Get total topic views -- END


Find:

Code: Select all

   'TOTAL_USERS'   => sprintf($user->lang[$l_total_user_s], $total_users),


After add:

Code: Select all

   'TOTAL_VIEWS'   => $user->lang['TOTAL_VIEWS'] . ' <strong>' . $total_views . '</strong>',


Open styles/prosilver/template/index_body.html
Find:

Code: Select all

&bull; {TOTAL_TOPICS}


After add:

Code: Select all

 &bull; {TOTAL_VIEWS}


Open styles/subsilver2/template/index_body.html
Find:

Code: Select all

{TOTAL_POSTS} | {TOTAL_TOPICS}


After add:

Code: Select all

 | {TOTAL_VIEWS}


[...]


I hope that helps you. ;)
User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 5494
Joined: Tue Oct 30, 2007 10:57 pm
Location: Munich, Germany
Name: Marc
Contact:

Re: Why not a "Total Views"

by Abera » Wed Jul 21, 2010 4:53 pm

That did it Marc and thank you very much!
Abera
Registered User
Posts: 674
Joined: Mon Jan 15, 2007 1:26 am
Contact:

Re: Why not a "Total Views"

by Abera » Fri Jul 23, 2010 9:09 pm

Abera wrote:That did it Marc and thank you very much!


Sorry Marc, but ater looking at my local I'm seeing:

Total posts 3479 • Total topics 896 • Total topic views 24772 • Total active ads: 1 • Total images 9 • Total members 622 • Our newest member

Please notice the Total topic views 24772. Although looking at a topic it does show the increase, but I don't see the hits to the site. I'm not seeing Total Views as in the code.

'TOTAL_VIEWS' => $user->lang['TOTAL_VIEWS'] . ' <strong>' . $total_views . '</strong>',

I went back over all of the edits and they are right. Any suggestions?
Thanks
Abera
Registered User
Posts: 674
Joined: Mon Jan 15, 2007 1:26 am
Contact:

Re: Why not a "Total Views"

by wen_soon » Fri Feb 17, 2012 12:12 am

any way of adding these "total topic views" to each forum category/sub category, instead of a 'total topic views" for the entire forum? for example, an additional number below the "number of topics" column?
wen_soon
Registered User
Posts: 11
Joined: Tue Jan 31, 2012 4:56 pm
Contact:

Re: Why not a "Total Views"

by ronjan » Fri Apr 19, 2013 11:14 am

Hi, Thanks this works great.
I even added it to the viewforum and viewtopic.php to show the total views count.

I have a question:
How can I get it, so the total views count does NOT go down after a forum prune, as describe here, where it is done for topic and post counts:
viewtopic.php?f=46&t=2118407
ronjan
Registered User
Posts: 78
Joined: Wed Feb 06, 2013 7:36 am
Contact:

Re: Why not a "Total Views"

by Oyabun1 » Fri Apr 19, 2013 12:15 pm

ronjan wrote:I have a question:
How can I get it, so the total views count does NOT go down after a forum prune, as describe here, where it is done for topic and post counts:
viewtopic.php?f=46&t=2118407
That's different because as well as the record in the topics and posts table the total count of those is added as fields in the config table and Noxwizard's changes in that other table were just to stop the change to the values in the in the config table.

However, topic_views is not in the config table it is just a column in the topics table with a value for each topic. Marc's code above just adds those values together to get a total view count. When a topic is removed its topic_views value is also removed and therefore the total is reduced. You can't remove the row for the topic and yet have its topics_view field remain.

To not alter the topic_views would require a lot more than just altering a line or two of code.
                      Support Request Template
3.0.x: Knowledge Base Styles Support MOD Requests
3.1.x: Knowledge BaseStyles SupportExtension Requests
User avatar
Oyabun1
Former Team Member
Posts: 23162
Joined: Sun May 17, 2009 1:05 pm
Location: Australia
Name: Bill
Contact: