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

Reply
 
Thread Tools Display Modes
  #1  
Old 02-04-2013, 11:33 PM
LifesGreatestGift's Avatar
LifesGreatestGift LifesGreatestGift is offline
 
Join Date: Jul 2009
Location: Louisville, KY USA
Posts: 885
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default first post counted as reply in custom script

I am working on building a classifieds section on my forum and the current code is counting the first post of a thread as a reply. is there a way around this? Here is my current code

Code:
$cats = array(18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68);

foreach ($cats AS $cat => $forumid) { 
$t_count[$forumid] = array( 
    "forumid" => $forumid,  
    "forum_name" => $vbulletin->forumcache[$forumid]['title'],  
    "threadcount" => vb_number_format($vbulletin->forumcache[$forumid]['threadcount']),  
    "replycount" => vb_number_format($vbulletin->forumcache[$forumid]['replycount']) 
    ); 
} 
foreach ($cats AS $cat) { 
    $total_count_thread += vb_number_format($vbulletin->forumcache[$cat]['threadcount']); 
    $total_count_reply += vb_number_format($vbulletin->forumcache[$cat]['replycount']); 
} 
  
$classifieds = array_merge($t_count);  

if (is_member_of($vbulletin->userinfo, 6)) {  
/* print_r($total_count_reply);  
echo "<br />"; 
print_r($total_count_thread); */ 
}  

vB_Template::preRegister('FORUMHOME',array('classifieds' => $classifieds)); 
vB_Template::preRegister('FORUMHOME',array('total_count_thread' => $total_count_thread)); 
vB_Template::preRegister('FORUMHOME',array('total_count_reply' => $total_count_reply));
Here is where its rendered

https://www.thesecond.org/forum/#classifieds

if i make a "classified" aka thread, my "Listings" and "Replies" count is 1 when I'd like it to be Listings: 1 Replies: 0

Hope that makes sense.

Thanks in advance!
Reply With Quote
  #2  
Old 02-05-2013, 01:03 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It looks like the forum replycount is the number of posts including the first in each thread. But it seems like you should be able to get what you want by subtracting the threadcount from the replycount.

By the way, that's a very cool map you have there.
Reply With Quote
  #3  
Old 02-05-2013, 01:34 AM
LifesGreatestGift's Avatar
LifesGreatestGift LifesGreatestGift is offline
 
Join Date: Jul 2009
Location: Louisville, KY USA
Posts: 885
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks! yeah, I cant remember, but does default vB4 in a brand new forum, when a new thread is made with its only post, does it show as 1 thread 1 reply, or 1 thread 0 replies ?
Reply With Quote
  #4  
Old 02-05-2013, 01:37 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I just made a new forum on my test site to check and it looks like the thread replycount field counts only replies after the first, but the forum replycount field (which it looks like you're using in the code you posted) counts every post including the first. So in my new forum (with one thread with only the first post), when I'm looking at it in the list of forums it shows 1 Thread and 1 Post, but when I list the threads in the forum, that thread shows 0 replies.
Reply With Quote
Благодарность от:
LifesGreatestGift
  #5  
Old 02-05-2013, 01:44 AM
LifesGreatestGift's Avatar
LifesGreatestGift LifesGreatestGift is offline
 
Join Date: Jul 2009
Location: Louisville, KY USA
Posts: 885
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome. Thanks! The Threads minus Replies is a really good idea. I will implement that! Thanks again! And congrats on the mod position.

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

* Replies minus Threads

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

Here is the new revised code for anyone wondering

Code:
$cats = array(18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68);

foreach ($cats AS $cat => $forumid) {  
$t_count[$forumid] = array(  
    "forumid" => $forumid,   
    "forum_name" => $vbulletin->forumcache[$forumid]['title'],   
    "threadcount" => vb_number_format($vbulletin->forumcache[$forumid]['threadcount']),   
    "replycount" => vb_number_format(($vbulletin->forumcache[$forumid]['replycount']) - ($vbulletin->forumcache[$forumid]['threadcount']))  
    );  
}  
foreach ($cats AS $cat) {  
    $total_count_thread += vb_number_format($vbulletin->forumcache[$cat]['threadcount']);  
    $total_count_reply += vb_number_format(($vbulletin->forumcache[$cat]['replycount']) - ($vbulletin->forumcache[$cat]['threadcount']));  
}  
   
$classifieds = array_merge($t_count);   

if (is_member_of($vbulletin->userinfo, 6)) {   
/* print_r($total_count_reply);   
echo "<br />";  
print_r($total_count_thread); */  
}   

vB_Template::preRegister('FORUMHOME',array('classifieds' => $classifieds));  
vB_Template::preRegister('FORUMHOME',array('total_count_thread' => $total_count_thread));  
vB_Template::preRegister('FORUMHOME',array('total_count_reply' => $total_count_reply));
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 05:55 AM.


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.06075 seconds
  • Memory Usage 2,211KB
  • Queries Executed 13 (?)
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)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (1)post_thanks_box_bit
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (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_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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • 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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete