vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   Customizing VSa - Chatbox with user avatars (https://vborg.vbsupport.ru/showthread.php?t=315913)

MarkFL 12-08-2014 10:00 PM

Customizing VSa - Chatbox with user avatars
 
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. :cool:

MarkFL 12-12-2014 12:54 AM

[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! :D

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. :cool:

Lynne 12-12-2014 01:22 AM

Thank you for posting the solution to your problem. Hopefully it will help someone else who has the same issue.

chikuru 12-12-2014 04:27 AM

Thank you for this! I was also trying to code this.

M.C. 05-02-2016 07:12 AM

thanks, great addon!

TheLastSuperman 05-02-2016 06:56 PM

Moved to articles :cool:. Also made second post the first post then pasted old first post code into second with strike-through - for reference only ;).

GHRake 05-08-2016 03:00 PM

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

https://vborg.vbsupport.ru/external/2016/05/26.png

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


MarkFL 05-08-2016 03:13 PM

1 Attachment(s)
I kind of went wild when I was learning javascript and made quite a few changes to the chat:

https://vborg.vbsupport.ru/attachmen...1&d=1462727590

GHRake 05-09-2016 02:05 AM

Quote:

Originally Posted by MarkFL (Post 2570358)
I kind of went wild

Yes you did! Site looks great BTW

MarkFL 05-09-2016 02:09 AM

Quote:

Originally Posted by GHRake (Post 2570386)
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. :D


All times are GMT. The time now is 09:09 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.01284 seconds
  • Memory Usage 1,753KB
  • 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
  • (7)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete