Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-02-2010, 08:38 PM
IR15H IR15H is offline
 
Join Date: Feb 2007
Location: England
Posts: 161
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Widget - Stats help

Hi,

I'm trying convert "Forum Statistics", displayed at the bottom of forum.php into a widget by following Cellarius' Rendering templates and registering variables guide and by cross referencing with Lynne's "Who's Online" mod, but I'm not having much joy. Below are the steps I took;
  1. Create a new template
    • Admin CP > Styles & Templates > Style Manager > Add New Template
    • Title
      Quote:
      vbcms_widget_execphp_stats
    • Template
      HTML Code:
      <div class="cms_widget">
          <div class="block">
              <div class="cms_widget_header">
                  <h3><img src="{vb:stylevar imgdir_misc}/forum_stats.png" title="{vb:raw widget_title}" alt="" /> {vb:raw widget_title}</h3>
              </div>
              <div class="cms_widget_content">
                  <div>
                                              <dl>
      						<dt>{vb:rawphrase threads}</dt>
      							<dd>{vb:raw totalthreads}</dd>
      						<dt>{vb:rawphrase posts}</dt>
      							<dd>{vb:raw totalposts}</dd>
      						<dt>{vb:rawphrase members}</dt>
      							<dd>{vb:raw numbermembers}</dd>
      						<vb:if condition="$show['activemembers']">
                                                      <dt>{vb:rawphrase active_members}</dt>
                                                               <dd>{vb:raw activemembers}</dd>
                                                      </vb:if>
      					</dl>
      					<p>{vb:rawphrase welcome_to_our_newest_member_x, {vb:link member, {vb:raw newuserinfo}}, {vb:raw newuserinfo.username}}</p>
                  </div>
              </div>
          </div>
      </div>
  2. Create a widget
    • ADMIN CP > vBulletin CMS > Widgets > Create New Widget
      • Widget Type: PHP Direct Execution
      • Title: Statistics
      • Description: Site Statistics.
  3. Configure widget
    • Enter PHP Direct (taken from forum.php);
      PHP Code:
      // get total threads & posts from the forumcache
      $totalthreads 0;
      $totalposts 0;
      if (
      is_array($vbulletin->forumcache))
      {
          foreach (
      $vbulletin->forumcache AS $forum)
          {
              
      $totalthreads += $forum['threadcount'];
              
      $totalposts += $forum['replycount'];
          }
      }
      $totalthreads vb_number_format($totalthreads);
      $totalposts vb_number_format($totalposts);

      // get total members and newest member from template
      $numbermembers vb_number_format($vbulletin->userstats['numbermembers']);
      $newuserinfo = array(
          
      'userid'   => $vbulletin->userstats['newuserid'],
          
      'username' => $vbulletin->userstats['newusername']
      );
      $activemembers vb_number_format($vbulletin->userstats['activemembers']);
      $show['activemembers'] = ($vbulletin->options['activememberdays'] > AND ($vbulletin->options['activememberoptions'] & 2)) ? true false;


          
      $stats = array('totalthreads' => $totalthreads,
          
      'totalposts' => $totalposts,
          
      'numbermembers' => $numbermembers,
          
      'activemembers' => $activemembers,
          
      'newuserinfo' => $newuserinfo,
          );
          
          
      vB_Template::preRegister('vbcms_widget_execphp_stats'$stats); 
    • Template Name
      Quote:
      vbcms_widget_execphp_stats

From looking at the guide, I (incorrectly?) thought I defined the array I wanted to use, which includes all my variables, and then registered it for use in my pre-existing template. However, something is wrong as my outcome is;


The only difference in methodology I can find is the inclusion of "require_once(DIR . '/includes/functions_bigthree.php'); " at the start of the PHP in Lynne's mod. I don't really understand it, but I think it's basically needed because something required for the mod to work is defined within functions_bigthree.php? As my threads is currently displaying 0, I'm guessing that "threadcount" (amongst others) hasn't been defined properly, as it's not adding this value onto 0.

I did a search for "functions" files containing"threadcount" and discovered it contained within the following files;
  • includes/functions.php
  • includes/functions_databuild.php
  • includes/functions_forumdisplay.php
  • includes/functions_forumlist.php

I then tried adding these to top of the widget PHP via require_once(DIR . '/includes/functions_filename.php');, but to no avail. I'm now at a dead end as to what to try next to get it to work so any help would be appreciated.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:42 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03176 seconds
  • Memory Usage 2,236KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_html
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)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)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadedmode.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete