vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Live Forum Statistics in Header Template (https://vborg.vbsupport.ru/showthread.php?t=95495)

Neutral Singh 09-01-2005 10:00 PM

Live Forum Statistics in Header Template
 
Live Forum Statistics in Header Template
Should work in all vB 3.0.x series


I have absolutely no clue, who had originally written this bit of code as i only found this in a post somewhere, a long long times back (can't recollect). I would be more than glad to know the original writer of this useful code to give proper credit.

Requested by :
Myself [img]images/newsm/devious.gif[/img]

Context :
Searched through vb.org but could not find a similar plugin/hack for vB3.5/vB3.0.x. I wanted to show all vital forum stats like total posts, total threads, total members and newest member on each page of my forum as well as vBa CMPS, in header template and this plugin performs exactly the same function.

What this hack does ?
Stores the desired information from your forum database into php variables and when called in 'header 'template, produces the desired results.

Utility :
Imagine... an unregistered/guest visits your website for the first time via a search engine link (95% of times its not the homepage that is found via a search engines link) and the first thing s/he notices is the forum header information and says wow!! this forum has got xxxx members, xxxxx threads, xxxxxx posts, why not get registered with this community and see what this forum has got in store for me. LOL!! quite true actually. [img]images/newsm/wink.gif[/img]

Demo : http://www.sikhphilosophy.net

Any Screenshots : Demo is self-explanatory above.

Warning: This hack executes 5 queries per page.

Installation Instructions : (Also attached.)

Code:

Step by Step Instructions:

1. In the 'header' template:

Find: (ususally at the end of the template file)

<!-- content table -->
$spacer_open


Add Above:
<!-- Forum Stats in Header Template -->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
        <td>
          <div align="left">| Discussions: $totalthreads | Messages: $totalposts | Members: $numbermembers | Online: $totalonline  | Newest :

Code:

$newusername(Welcome!)
</span>
        </td>
  </tr>
</table>
<!-- Forum Stats in Header Template -->


Ofcourse you can customise this code to suit your website setup. ;)


2. In phpinclude_start template add the following code at the end.

// forum stats start
        $numbersmembers=$DB_site->query_first("SELECT COUNT(*) AS users,MAX(userid) AS max FROM " . TABLE_PREFIX . "user");
        $numbermembers=number_format($numbersmembers['users']);
        $countposts=$DB_site->query_first("SELECT COUNT(postid) AS posts, COUNT(threadid) AS threads FROM " . TABLE_PREFIX . "post");
        $totalposts=number_format($countposts['posts']);
        $countthreads=$DB_site->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread");
        $totalthreads=number_format($countthreads['threads']);
// forum stats end

// total online start
        $datecut = TIMENOW - $vboptions['cookietimeout'];
        $headerguests=$DB_site->query_first("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "session WHERE userid=0 AND lastactivity>$datecut");
        $headerusers=$DB_site->query_first("SELECT COUNT(DISTINCT(userid)) AS count FROM " . TABLE_PREFIX . "session WHERE " . TABLE_PREFIX . "session.userid>0 AND " . TABLE_PREFIX . "session.lastactivity>$datecut");
        $headerguests=$headerguests[count];
        $headerusers=$headerusers[count];
        $totalonline=$headerguests+$headerusers;
// total online end

// get newest member name and userid start
        $getnewestmember=$DB_site->query_first("SELECT userid, username FROM " . TABLE_PREFIX . "user WHERE " . TABLE_PREFIX . "userid=$numbersmembers[max]");
        $newusername = $getnewestmember['username'];
        $newuserid = $getnewestmember['userid'];
// get newest member name and userid end




And you are done!!

Please dont forget to click Install

Enjoy !!

Nordinho 09-02-2005 05:09 PM

looks really good...I guess I need to disable the info at the bottom of forumhome to save some queries??

Koopa 09-03-2005 07:02 PM

Looks good :) Nice one.

vakvak 09-04-2005 01:41 AM

thanks

Thug 09-04-2005 01:00 PM

nice work duno if i will use it yet

HHU 09-28-2005 02:31 AM

Installed.. thanks

Actually, how would I create it so that you can click on the newest member and it will go to their userid profile page?

Neutral Singh 10-31-2005 03:15 AM

** Template hack updated for forums using table_prefixes **

Enjoy !!


All times are GMT. The time now is 10:02 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01100 seconds
  • Memory Usage 1,735KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete