vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Creating a counter (https://vborg.vbsupport.ru/showthread.php?t=176646)

WarriorDL 04-19-2008 07:05 PM

Creating a counter
 
1 Attachment(s)
Hi. I'm trying to create a counter that reads how many categories and images I have in my gallery.

The vB code for total threads and and posts is like what I want, as the category and image totals will replace the threads and posts totals.

PHP Code:

$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); 

The original coding is from another script:

PHP Code:

$total_images 0;
$total_categories 0;

$cache_id create_cache_id(
  
'data.auth_and_info',
  array(
$user_info[$user_table_fields['user_id']])
);

if (!
$data get_cache_file($cache_idnull)) {
  if (!empty(
$cat_cache)) {
    foreach (
$cat_cache as $key => $val) {
      if (
check_permission("auth_viewcat"$key)) {
        
$total_categories++;
        if (isset(
$val['num_images'])) {
          
$total_images += $val['num_images'];
        }
        else {
          
$cat_cache[$key]['num_images'] = 0;
        }
        
$auth_cat_sql['auth_viewcat']['IN'] .= ", ".$key;
      }
      else {
        
$auth_cat_sql['auth_viewcat']['NOTIN'] .= ", ".$key;
      }
    }
  }

  
$data = array();

  
$data['total_images'] = $total_images;
  
$data['total_categories'] = $total_categories;
  
$data['auth_viewcat']['IN'] = $auth_cat_sql['auth_viewcat']['IN'];
  
$data['auth_viewcat']['NOTIN'] = $auth_cat_sql['auth_viewcat']['NOTIN'];

  
save_cache_file($cache_idserialize($data));

} else {
  
$data unserialize($data);

  
$total_images $data['total_images'];
  
$total_categories $data['total_categories'];
  
$auth_cat_sql['auth_viewcat']['IN'] = $data['auth_viewcat']['IN'];
  
$auth_cat_sql['auth_viewcat']['NOTIN'] = $data['auth_viewcat']['NOTIN'];


It won't work in my non-forum vB generated page.

Opserty 04-19-2008 07:41 PM

What is the template code you are using to display it?

WarriorDL 04-19-2008 07:50 PM

It's just a phrase in there right now, not the phrase and variables.

It's in the "What's Happening" section of the FORUMHOME template. However, I have created a seperate template for my non-forum page to get that info.

If I switch the variable in the template back to the forum stats, it *does* work for that. But obviously this isn't a forums page. It's going to be a gallery page, thus wanting gallery stats, not forum stats :)

--------------- Added [DATE]1208643394[/DATE] at [TIME]1208643394[/TIME] ---------------

To get an idea of what I am doing over all, look here: http://www.colonialfleets.com/gallery/

The vB is vB 3.0 with 4Images using the user and groups from the forums.

However, with vB 3.6.x, 4Images won't work with it anymore.

So what I am going to try to do is create my own gallery system based on the "goodies" 4Images offers, but mine will be a plug-in to vB.

To do that, all of the coding has to be written in vB type, which means a complete over-haul. I'm willing to do that, but may need a directional point once in a while.

I've searched all over on how to create a totals counter, and all I can find is visitor counters, which do me no good.

--------------- Added [DATE]1208648270[/DATE] at [TIME]1208648270[/TIME] ---------------

Fixed it! Whoo Hooo!

PHP Code:

$result $db->query("SELECT * FROM " TABLE_PREFIX "my categories table here"); //Change the table name
$total_categories mysql_num_rows($result);

$result $db->query("SELECT * FROM " TABLE_PREFIX "my images table here"); //Change the table name
$total_images mysql_num_rows($result); 



All times are GMT. The time now is 05:56 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.01832 seconds
  • Memory Usage 1,742KB
  • 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
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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