View Full Version : Forum Home Enhancements - Total Thread Hits Per Forum
eXtremeTim
08-19-2002, 10:00 PM
This hack counts the total thread hits for each forum then displays it where every you put the variable. This hack adds one querie per forum unless the forum has no posts in it then it doesn't add on for that forum. It also currently does not count sub forums. I plan to work on that soon.
Demo: http://www.extremechatforums.com/forum/ look under any forum after the description where it says [New Thread]
Attrox
08-20-2002, 01:41 AM
Hmm...pretty cool, nice job. I'm not sure if I'm going to install it though, at least not yet.
Erwin
08-20-2002, 01:48 AM
Your forum index page has 127 queries! :eek:
You might want to reduce it a bit before your forums get too busy and your host gets upset. :)
Erwin
08-20-2002, 01:49 AM
This is partly due to your own hack actually - if you have 40 forums listed on your index page, you have 40 extra queries. It may not be a problem now, but trust me, your server load will be enormous when your site gets busier.
eXtremeTim
08-20-2002, 02:10 AM
No my quiries are way up there more or less from the sub forums hack.
eXtremeTim
08-20-2002, 02:13 AM
now im down to 74 quiries
eXtremeTim
08-20-2002, 02:15 AM
Originally posted by eXtremeTim
This hack adds one querie per forum unless the forum has no posts in it then it doesn't add on for that forum.
Just thought that i would point out the fact that i stated Erwin pointed out already. :)
joeboo
08-20-2002, 03:25 AM
Hmm.. interesting hack, i may install this. So.. let me get this straight, it adds one querie per forum? so if i have 10 forums, it adds 10 queries?
Schorsch
08-20-2002, 02:26 PM
as soon as your hack assists subforums I'll install it.
cu
Schorsch
NTLDR
08-20-2002, 02:45 PM
Originally posted by joeboo
Hmm.. interesting hack, i may install this. So.. let me get this straight, it adds one querie per forum? so if i have 10 forums, it adds 10 queries?
Yep :(
From his forums:
Page generated in 0.94005299 seconds (34.23% PHP - 65.77% MySQL) with 73 queries.
Nice hack, but 73 queries is not good.
Schorsch
08-20-2002, 07:14 PM
isn't there a chance to reduce the queries ?? 73 queries, that's crazy :bunny:
eXtremeTim
08-20-2002, 07:35 PM
my site has alot of other stuff i only have liek 25 quiries from this hack.
NTLDR
08-20-2002, 07:45 PM
25 is still alot, you should try and keep the number bellow 30 and a standard vB.org 23 on the forum home page, adding this hack you add another 18 queries, nearly as much as the forum home page itself :(
eXtremeTim
08-20-2002, 08:05 PM
I know. Im not sure if there is a way to optimise this hack tho. If somebody knows a way please speak up.
eXtremeTim
08-20-2002, 08:25 PM
I just thought of a way to possible clean this up. :) I will work on it tonight and see what i come up with.
eXtremeTim
08-20-2002, 08:29 PM
Here let me tell you the idea.
I make a column on the forum table and add to the hit tracking line for show thread to have it add to the proper forum. If i do sub forums i will need some kind of stat updater for it. So if you move a forum or restructure your hits are not all wacked up.
What ya think.
eXtremeTim
08-21-2002, 07:29 PM
I got the new method working. I just have to make a hit update part and i think it will be ready for release. :)
eXtremeTim
08-21-2002, 07:43 PM
Im about to beta test the update script and if it works then i will document it up and get the new version out. :) This one shouldn't even add a querie to forum home. Just adds like another thread hit type querie. :)
IT also supports sub forums. :)
eXtremeTim
08-22-2002, 02:10 AM
The new version will be delayed a few days as im having some very wierd bugs. Some forums the sub forums get counted with the updated script and added to the parent forums but then some don't. And the showthread.php part is only updating the count for the forum and not its parents for some reason. Even tho both parent forums and the forums numbers are being called. So i have alot of work ahead of my to finish fixing the last 2 major bugs. But i got half of it working. :)
see if this works. I stole it from a different hack that FireFly cleaned up and it seemed like it would work here too.
everything is new, so delete the old code
right above this
// Start makeforumbit
add this
$getforumviews = $DB_site->query('
SELECT sum(views) AS hits, forumid
FROM thread
GROUP BY forumid
');
$forumviews = array();
while ($getforumview = $DB_site->fetch_array($getforumviews)) {
$forumviews[$getforumview['forumid']] = $getforumview['hits'];
}
then right above this
eval("\$forumbits .= \"".gettemplate("forumhome_forumbit_level$depth$tempext")."\";");
add this
global $forumviews;
$forumhits = $forumviews[$forum['forumid']];
if (intval($forumhits) < 1) {
$forumhits = 0;
}
now add the var $forumhits where you want the number of total views per forum to appear. this should only add 1 querry regardless of the number of forums.
once my server is back up, I'll be installing this.
Katman
10-11-2002, 01:00 AM
You don't mention what files this hack needs to be placed in? Do I update the code in the index.php or fourmdisplay.php or both? Because "// Start makeforumbit" is listed in both of them in vB 2.2.8.
shanx25
04-16-2004, 02:12 PM
I am thinking about the same problem.
The best way of doing this imho is to have a "totalviews" column in the FORUM table. I keep updating this totalviews section on an hourly basis with a GROUPBY SQL similar to the one you use. It takes 0.0008 seconds on my server.
Now that this info is already in FORUM table, we can get this column along with the same SQL that gets all the other stuff.
In other words, there is *NO ADDITIONAL* query required.
Here is what I did:
1. Altered the "Forum" table to ADD an additional column:
"totalviews" (int(10))
2. Then, set up a cronjob to execute this code hourly (you can change timing to whatever you want of course) -- cron_update_forum_totalviews.php.txt. This code takes the total of all threads and puts them into the forum.
3. /includes/functions_forumlist.php
Find every occurence of replycount, and add the "totalviews" in a similar fashion. The attached /includes__functions_forumlist.php.txt file should tell you what I have added. Just search for the word replycount inside this file.
4. index.php
Find this code:
if (is_array($forumcache))
This is the section where there are some references to "Replycount". I added stuff for "totalviews" so that my code looks like this:
// get total threads & posts from the forumcache
$totalthreads = 0;
$totalposts = 0;
$totalviews = 0;
if (is_array($forumcache))
{
foreach ($forumcache AS $forum)
{
$totalthreads += $forum['threadcount'];
$totalposts += $forum['replycount'];
$totalviews += $forum['totalviews'];
}
}
$totalthreads = vb_number_format($totalthreads);
$totalposts = vb_number_format($totalposts);
$totalviews = vb_number_format($totalviews);
Of course, all changes are included in the attached index.php.txt
Hope this helps someone in the future include VIEWS on forumhome (forum's home page). Let me know how it works out. I have it in a BBS that's under a password protected website, so cannot show example, but works like a charm. No extra queries!
-S
Is it possible, to get this hack for vBulletin® Version 3.6.4 ?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.