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

Reply
 
Thread Tools Display Modes
  #1  
Old 05-07-2012, 11:13 AM
postchan postchan is offline
 
Join Date: Dec 2007
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Total Posts under user statistics

On the user profile page, Total Posts under user statistics shows both the replies he made or the threads he started as one total count. Is there a way I can split this count into Threads and Posts and display it?

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

I forgot to mention I have vB 3.8.x
Reply With Quote
  #2  
Old 05-07-2012, 01:13 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you create a plugin using hook location userprofile_create and this code:

Code:
if ($threads = $registry->db->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread WHERE postuserid = $userinfo[userid] AND open=1 AND visible=1"))
{
    $this->prepared['threads'] = $threads['threads'];
    $this->prepared['replys'] = $userinfo['posts'] - $threads['threads'];
}

then you can edit any of the block templates and insert $prepared[threads] and $prepared[replys].
Reply With Quote
  #3  
Old 05-07-2012, 02:52 PM
postchan postchan is offline
 
Join Date: Dec 2007
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks so much! It worked like a charm!
Reply With Quote
  #4  
Old 05-07-2012, 03:33 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Now that I look at it again, you might want to take out "AND open=1" from the query, because that will cause it not to count closed threads which probably isn't what you want.
Reply With Quote
  #5  
Old 05-08-2012, 01:58 PM
postchan postchan is offline
 
Join Date: Dec 2007
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi kh99,

Thanks. I need another bit of info. Can I use the same code to create another plugin for displaying this count in each post. I presume you need the postbit_display_complete hook. Please help.
Reply With Quote
  #6  
Old 05-08-2012, 02:04 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could - I haven't tested it but this might work.

Code:
if ($threads = $vbulletin->db->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread WHERE postuserid = $post[userid] AND visible=1"))
{
    $post['threads'] = $threads['threads'];
    $post['replys'] = $post['posts'] - $threads['threads'];
}

But this adds one db query per displayed post. It would be better to do something like add a threads column to the user table and manage the value the same way the user post count is managed, but of course that would be more complicated.
Reply With Quote
  #7  
Old 05-08-2012, 02:13 PM
postchan postchan is offline
 
Join Date: Dec 2007
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I tried as you said but it gives me the following fatal error:

Fatal error: Call to a member function query_first() on a non-object in /public_html/forums/includes/class_postbit.php(294) : eval()'d code on line 56
Reply With Quote
  #8  
Old 05-08-2012, 02:15 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oh yeah...you need to add

Code:
global $vbulletin;

as the first line of the plugin code.
Reply With Quote
  #9  
Old 05-08-2012, 02:23 PM
postchan postchan is offline
 
Join Date: Dec 2007
Posts: 15
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I added the first line but the error persists. I added $post[threads] and $post[replys] in my template. Is that a prob?
Reply With Quote
  #10  
Old 05-08-2012, 02:31 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, I tested this code and it seems to work:

Code:
global $vbulletin;

if ($threads = $vbulletin->db->query_first("SELECT COUNT(*) AS threads FROM " . TABLE_PREFIX . "thread WHERE postuserid = $post[userid] AND visible=1"))
{
    $post['threads'] = $threads['threads'];
    $post['replys'] = $post['posts'] - $threads['threads'];
}

Yes, adding $posts[threads] and $posts[replys] is what you want to do.

(I guess that should really have been "replies" ).
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 09:10 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.04538 seconds
  • Memory Usage 2,248KB
  • 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)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete