Thread: Forum Home Enhancements - Total Thread Hits Per Forum
View Single Post
  #25  
Old 04-16-2004, 02:12 PM
shanx25 shanx25 is offline
 
Join Date: Apr 2004
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
PHP 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:

PHP Code:
// 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
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01205 seconds
  • Memory Usage 1,782KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete