Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
Who Posted in SHOWTHREAD Details »»
Who Posted in SHOWTHREAD
Version: 1.00, by grey_goose grey_goose is offline
Developer Last Online: Mar 2020 Show Printable Version Email this Page

Category: Show Thread Enhancements - Version: 4.2.2 Rating:
Released: 09-21-2015 Last Update: Never Installs: 5
Uses Plugins Template Edits
Re-useable Code  
No support by the author.

I wanted to be able to show who had participated in a given thread within the thread. This is available via WHOREAD in the forum listing, but it didn't feel as intuitive. Now, users can see immediately who's posted in a given thread.

What's involved:
1. Create a plugin
2. Create a template to display plugin info
3. Create a replacement variable
3. Edit SHOWTHREAD to call the template

Creating the plugin
This is pretty much a straight copy of the code from misc.php into a plugin, and registering the variable (thanks Lynne).
1. Admincp > Plugins & Products > Add New Plugin
Product: Vbulletin
Title: Who Posted in Showthread
Hook Location: showthread_start
Execution Order: 5
Code:
PHP Code:
if (!$threadinfo['threadid'] OR $threadinfo['isdeleted'] OR (!$threadinfo['visible'] AND !can_moderate($threadinfo['forumid'], 'canmoderateposts')))
    { 
        eval(
standard_error(fetch_error('invalidid'$vbphrase['thread'], $vbulletin->options['contactuslink']))); 
    } 

    (
$hook vBulletinHook::fetch_hook('misc_whoposted_start')) ? eval($hook) : false;

    
$posts $db->query_read_slave(
        SELECT COUNT(postid) AS posts, 
            post.username AS postuser,user.userid,user.username 
        FROM " 
TABLE_PREFIX "post AS post 
        LEFT JOIN " 
TABLE_PREFIX "user AS user USING(userid) 
        WHERE threadid = 
$threadinfo[threadid] 
            AND visible = 1 
        GROUP BY userid 
        ORDER BY posts DESC 
    "
); 

    
$totalposts 0
    
$posters ''
    if (
$db->num_rows($posts)) 
    { 
        require_once(
DIR '/includes/functions_bigthree.php'); 
        while (
$post $db->fetch_array($posts)) 
        { 
            
// hide users in Coventry 
            
$ast ''
            if (
in_coventry($post['userid']) AND !can_moderate($threadinfo['forumid']))
            { 
                continue; 
            } 

            
exec_switch_bg(); 
            if (
$post['username'] == ''
            { 
                
$post['username'] = $post['postuser']; 
            } 
            
$post['username'] .=  $ast
            
$totalposts += $post['posts']; 
            
$post['posts'] = vb_number_format($post['posts']); 
            
$show['memberlink'] = iif ($post['userid'], truefalse); 
            
$templater vB_Template::create('showthreadwhoposted'); 
                
$templater->register('bgclass'$bgclass); 
                
$templater->register('post'$post); 
                
$templater->register('threadinfo'$threadinfo); 
            
$posters .= $templater->render(); 
        } 
        
$totalposts vb_number_format($totalposts); 

        (
$hook vBulletinHook::fetch_hook('misc_whoposted_complete')) ? eval($hook) : false;
         
            
$templater->register_page_templates(); 
            
$templater->register('posters'$posters); 
            
$templater->register('threadinfo'$threadinfo); 
            
$templater->register('totalposts'$totalposts); 
            
        
vB_Template::preRegister('SHOWTHREAD', array('posters' => $posters));  
    } 
Plugin is Active: Yes

Creating the template
Sharp eyes will have caught that the template is going to be named "showthreadwhoposted". I'm super original like that.
1. Styles and Templates > Style Manager > Add New Template
Title: showthreadwhoposted
Template:
PHP Code:
<div style="margin-right: 3px; float: right; margin-bottom: 3px; max-width: 30px; overflow: hidden;">
     <
a href="{vb:link member, {vb:raw post}}" title="{vb:raw post.username}">
          <
img height="30" src="http://nwod.org/forum/image.php?u={vb:link member, {vb:raw post}}"  />                                    
     </
a>
</
div
Note that this template creates 30px avatars that float. You can choose to make a simple list of username links, or resize the avatars, however you like. This is just how I wanted them displayed.

Create a replacement variable
Vbulletin isn't super helpful when it comes to calling avatars by username instead of userids, so we had to get a little bit hacky in the template above. This bit right here:
"http://nwod.org/forum/image.php?u={vb:link member, {vb:raw post}}"
Needs to be cleaned up.
1. Styles and Templates > Replacement Variable Manager > Add New Replacement Variable
Search for Text: image.php?u=member.php?
Replace with Text: image.php?u=

This strips out the raw link we called, leaving us with just the userid. If someone knows of a better way to call the userid, this might not be necessary and the Template could be edited.

Edit SHOWTHREAD to call the template
We've made the plugin fetch who's posted, rendered it into a template, and cleaned up the avatar image URL in said template. Now we just need to place the display of users who posted in the SHOWTHREAD template.
1. Search in Templates > SHOWTHREAD (search Titles only) > Find
2. Search for the first occurence of "<vb:if condition="$pagenav">". This will position our list above the pagination and tools menu bar.
3. Add the following:
PHP Code:
        <div style="float: right; margin-top: 3px;">
            {
vbraw posters}
        </
div
This will create a floating list of posters.

If everything has been done properly you should see something like this:


My SHOWTHREAD is modified a bit, but you get the general idea. Right above the pagination is a list of avatars that link to the member's page.

Happy forum'ing!

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 09-24-2015, 12:59 PM
Alan_SP's Avatar
Alan_SP Alan_SP is offline
 
Join Date: Nov 2009
Posts: 1,122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It would be great if you make into mod, would be much easier to install.

Anyway, interesting idea. :up:
Reply With Quote
Благодарность от:
grey_goose
  #3  
Old 09-24-2015, 02:49 PM
Justinphx Justinphx is offline
 
Join Date: Jan 2012
Posts: 92
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Looks nice. What if a thread has 100+ posts within it? That would be a lot a avatars to display. Is there a way to limit it?
Reply With Quote
  #4  
Old 09-25-2015, 08:37 PM
grey_goose grey_goose is offline
 
Join Date: Jun 2009
Posts: 284
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Justinphx View Post
Looks nice. What if a thread has 100+ posts within it? That would be a lot a avatars to display. Is there a way to limit it?
There are a few ways to go about it (limit query) but the easiest might just to be to throw a MAX-HEIGHT: 35PX and OVERFLOW: HIDDEN on the container DIV.
Reply With Quote
  #5  
Old 10-08-2015, 06:36 AM
friendlymela's Avatar
friendlymela friendlymela is offline
 
Join Date: Dec 2012
Location: Karachi, Pakistan
Posts: 272
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is nice one..
Reply With Quote
Благодарность от:
grey_goose
Reply

Thread Tools

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 11:09 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.03796 seconds
  • Memory Usage 2,296KB
  • Queries Executed 19 (?)
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
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (2)post_thanks_box_bit
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (5)post_thanks_postbit_info
  • (4)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_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