Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles

Reply
 
Thread Tools
Customizing VSa - Chatbox with user avatars
MarkFL's Avatar
MarkFL
Join Date: Feb 2014
Posts: 3,853

I'm a relative newcomer to vBulletin administration, but I am enjoying every second of it, thanks in large part to the community here at vBorg.

St. Augustine, FL
Show Printable Version Email this Page Subscription
MarkFL MarkFL is offline 12-08-2014, 10:00 PM

How to display user avatars. We use the file system to store our avatars, so could not use the image.php?u=userid method.

To show avatars open the plugin titled "VSa - ChatBox - MN" and locate the line:

PHP Code:
$vsacb_msg_box_parsed str_replace('\''''', $vsacb_bbparser->do_parse($vsacb_msg_box_styled,1,$vsacb_smilies_onoff,1,1,1)); 
And after that, inserted the code:

PHP Code:
require_once('./includes/functions_user.php');
$avatar_url fetch_avatar_url($vsacb_msg_box['userid']);

$avatar $avatar_url[0];

if (!
$avatar)
{
    
$avatar './images/misc/unknown.gif';
}

$user_avatar '<img src="'.$avatar.'" border="0" width="48" style="vertical-align: middle" />';

vB_Template::preRegister('vsa_chatbox_bit',array('user_avatar' => $user_avatar)); 
Save the plugin, and then in the template "vsa_chatbox_bit" you may use "{vb:raw user_avatar}" to display the user avatars.
Reply With Quote
  #2  
Old 12-12-2014, 12:54 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[S]Hello all,

I am using vBulletin 4.2.1 on my local server as my dev site, and once done, I will go live with this on the forum I help administrate which runs vBulletin 4.2.2 patch level 2.

I am doing some custom hacks to Valter's great chatbox, and I am stumped on how to display user avatars. We use the file system to store our avatars, so I cannot use the image.php?u=userid method.

So, I have written a plugin, hook location is parse_templates, with the plugin PHP code:

PHP Code:
require_once('./includes/functions_user.php');
$avatar_url fetch_avatar_url($vbulletin->userinfo[$vsacb_msg_box.userid]);

$avatar $avatar_url[0];
$user_avatar '<img src="'.$avatar.'" border="0" width="40" style="vertical-align: middle" />';

vB_Template::preRegister('vsa_chatbox_bit',array('user_avatar' => $user_avatar)); 
Now, what I get is my avatar in every posted message, instead of the avatars of the users who actually posted the various messages. Can anyone tell me what I am missing? [/S]

I found the solution to my problem!

Instead of creating a new plugin, I hacked an existing one. I opened the plugin titled "VSa - ChatBox - MN" and located the line:

PHP Code:
$vsacb_msg_box_parsed str_replace('\''''', $vsacb_bbparser->do_parse($vsacb_msg_box_styled,1,$vsacb_smilies_onoff,1,1,1)); 
And after that, inserted the code:

PHP Code:
require_once('./includes/functions_user.php');
$avatar_url fetch_avatar_url($vsacb_msg_box['userid']);

$avatar $avatar_url[0];

if (!
$avatar)
{
    
$avatar './images/misc/unknown.gif';
}

$user_avatar '<img src="'.$avatar.'" border="0" width="48" style="vertical-align: middle" />';

vB_Template::preRegister('vsa_chatbox_bit',array('user_avatar' => $user_avatar)); 
Save the plugin, and then in the template "vsa_chatbox_bit" you may use "{vb:raw user_avatar}" to display the user avatars.
Reply With Quote
2 благодарности(ей) от:
chikuru, Lynne
  #3  
Old 12-12-2014, 01:22 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for posting the solution to your problem. Hopefully it will help someone else who has the same issue.
Reply With Quote
Благодарность от:
MarkFL
  #4  
Old 12-12-2014, 04:27 AM
chikuru chikuru is offline
 
Join Date: Nov 2011
Posts: 228
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for this! I was also trying to code this.
Reply With Quote
Благодарность от:
MarkFL
  #5  
Old 05-02-2016, 07:12 AM
M.C. M.C. is offline
 
Join Date: Jan 2002
Posts: 463
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks, great addon!
Reply With Quote
  #6  
Old 05-02-2016, 06:56 PM
TheLastSuperman's Avatar
TheLastSuperman TheLastSuperman is offline
Senior Member
 
Join Date: Sep 2008
Location: North Carolina
Posts: 5,844
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Moved to articles . Also made second post the first post then pasted old first post code into second with strike-through - for reference only .
Reply With Quote
Благодарность от:
MarkFL
  #7  
Old 05-08-2016, 03:00 PM
GHRake GHRake is offline
 
Join Date: Sep 2015
Location: USA
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is an awesome article, thank you!

In the img tag I set height="20" width="20" and it looks great with 14px text height



And if anyone was wondering where to place {vb:raw user_avatar} inside the vsa_chatbox_bit template, find:

PHP Code:
{vb:raw vsacb_msg_box.musername
And replace with:
PHP Code:
{vb:raw user_avatar} {vb:raw vsacb_msg_box.musername
Reply With Quote
2 благодарности(ей) от:
MarkFL, TheLastSuperman
  #8  
Old 05-08-2016, 03:13 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I kind of went wild when I was learning javascript and made quite a few changes to the chat:

Attached Images
File Type: jpg vsachat.jpg (77.4 KB, 0 views)
Reply With Quote
  #9  
Old 05-09-2016, 02:05 AM
GHRake GHRake is offline
 
Join Date: Sep 2015
Location: USA
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by MarkFL View Post
I kind of went wild
Yes you did! Site looks great BTW
Reply With Quote
  #10  
Old 05-09-2016, 02:09 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by GHRake View Post
Yes you did! Site looks great BTW
Thank you! The style was done by a hired designer, and we have added a lot of bells and whistles.
Reply With Quote
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 12:35 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.05074 seconds
  • Memory Usage 2,344KB
  • Queries Executed 26 (?)
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
  • (7)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (11)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (1)postbit_attachment
  • (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_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
  • 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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete