vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Widget - Stats help (https://vborg.vbsupport.ru/showthread.php?t=231972)

IR15H 01-02-2010 08:38 PM

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;
http://img682.imageshack.us/img682/759/23310562.png

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.

IR15H 01-07-2010 03:40 PM

Anyone? I've hit a brick wall in terms of trying to get this to work on my own.

kevinchappell 02-11-2010 11:04 PM

Did you ever figure this out?

IR15H 02-20-2010 03:12 PM

Quote:

Originally Posted by kevinchappell (Post 1980373)
Did you ever figure this out?

Hi, sorry for the late reply. No I didn't, however, someone else managed to get it to work and released it - https://vborg.vbsupport.ru/showthread.php?t=236403 :).


All times are GMT. The time now is 08:39 AM.

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.01870 seconds
  • Memory Usage 1,755KB
  • 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
  • (1)bbcode_html_printable
  • (1)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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