Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
AJAX Chat Integration Details »»
AJAX Chat Integration
Version: 1.00, by ICThawk ICThawk is offline
Developer Last Online: Mar 2014 Show Printable Version Email this Page

Category: Chat Modifications - Version: 4.1.4 Rating:
Released: 08-31-2011 Last Update: Never Installs: 15
Uses Plugins
Re-useable Code Translations  
No support by the author.

So I have been using vBulletin for awhile and have been very frustrated with the current lack of integration with AJAX Chat by blueimpu. So, I have decided to do the integration myself and with the help of other users on vB.org I have put together a few plugins.

Add Popup Link for Chat:
I started by adding in the Chat popup link to my navbar. In your navbar template, add the following code to display the Chat Link.

HTML Code:
<a class="navtab" href="#" onClick="MyWindow=window.open('http://www.wavingthewheat.com/chat/index.php','MyWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=800,height=600'); return false;">Chat ({vb:raw num_chatting})</a>
Next you will need to create a new plugin. Set the Hook Location to global_bootstrap_init_start and add the following into the PHP Code box.

PHP Code:
$result mysql_query("SELECT * FROM ajax_chat_online");   
$num_chatting mysql_num_rows($result);   
vB_Template::preRegister('navbar',array('num_chatting' => $num_chatting));
vB_Template::preRegister('FORUMHOME',array('num_chatting' => $num_chatting)); 


Displaying UserNames of Those Online:
Just like in the above there are two parts to this plugin. Modifying a template and creating a plugin. First we need to modify your FORUMHOME template. Right below the <!-- end logged in users --> line add the following.

HTML Code:
<!-- chat users -->
			<div id="wgo_onlineusers" class="wgo_subblock section">
				<h3 class="blocksubhead"><img src="{vb:stylevar imgdir_misc}/users_online.png" alt="Users In Chat" />{vb:raw num_chatting} Users In Chat</h3>
				<div>
					<p>{vb:raw chat_userlist}</p>
				</div>
			</div>
			<!-- end chat users -->
Next we need to create a new plugin. The Hook is global_start and the PHP code is:

PHP Code:
global $vbulletin;  

$results $vbulletin->db->query_read_slave("SELECT userName FROM ajax_chat_online");  
while (
$row $vbulletin->db->fetch_array($results))  
    
$chat_userlist[] = $row['userName'];  
if (
is_array($chat_userlist)) 

    
$chat_userlist implode(', '$chat_userlist);  
    
$vbulletin->db->free_result($results);  

else 

    
// set $chat_userlist to a "no one chatting" message if you want, or leave blank.
    
$chat_userlist ''

vB_Template::preRegister('FORUMHOME', array('chat_userlist' => $chat_userlist)); 

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
2 благодарности(ей) от:
Pianobiz, trueoak

Comments
  #2  
Old 09-01-2011, 03:12 PM
ICThawk ICThawk is offline
 
Join Date: Feb 2011
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Alright I have completed the project and updated the code above to display how I have mine setup. I hope this comes in handy for anyone else wanting to use AJAX chat.
Reply With Quote
  #3  
Old 09-04-2011, 11:40 AM
Feechen Feechen is offline
 
Join Date: Jul 2003
Location: Germany
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi,

I was so glad to find a description how to implement this. But I think there is a problem with vB 4.1.5.

I wanted to use the "Displaying UserNames of Those Online". I created the plugin and I inserted the code in forumhome. When I load my vB there is the following error message:

Warning: implode() [function.implode]: Invalid arguments passed in [path]/global.php(29) : eval()'d code (line 35)

Do you have an idea what I have done wrong?

Thank you in advance for your help.

Regards,
Feechen
Reply With Quote
  #4  
Old 09-06-2011, 03:40 PM
ICThawk ICThawk is offline
 
Join Date: Feb 2011
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Feechen, yes I had the same problem. It came from when there were NO users in chat it broke the code. I have added a "If Null" statement. I have fixed the "Display Users" Plugin Code above. But here it is again.

PHP Code:
global $vbulletin;  

$results $vbulletin->db->query_read_slave("SELECT userName FROM ajax_chat_online");  
while (
$row $vbulletin->db->fetch_array($results))  
    
$chat_userlist[] = $row['userName'];  
if (
is_array($chat_userlist)) 

    
$chat_userlist implode(', '$chat_userlist);  
    
$vbulletin->db->free_result($results);  

else 

    
// set $chat_userlist to a "no one chatting" message if you want, or leave blank.
    
$chat_userlist ''

vB_Template::preRegister('FORUMHOME', array('chat_userlist' => $chat_userlist)); 
Reply With Quote
  #5  
Old 03-23-2012, 01:59 PM
chrisbjax's Avatar
chrisbjax chrisbjax is offline
 
Join Date: Oct 2010
Location: Shakopee, MN
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi Hawk,
I'm trying to simply put the output in title tag like below, however, I'm just getting no echo.
Any thoughts on what I might be missing?
Thank you for your help.
Chris

HTML Code:
<a class="ajaxchat" style="float:left; position:relative; top:4px;" href="#" title="Chatting: {vb:raw chat_userlist}" onClick="ChatWindow=window.open('http://forums.usmilitarygamers.com/chat/index.php','ChatWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=800,height=600'); return false;">Chat ({vb:raw num_chatting})</a>
PHP Code:
$vbulletin;  

$results $vbulletin->db->query_read_slave("SELECT userName FROM ajax_chat_online");  
while (
$row $vbulletin->db->fetch_array($results))  
    
$chat_userlist[] = $row['userName'];  
if (
is_array($chat_userlist)) 

    
$chat_userlist implode(', '$chat_userlist);  
    
$vbulletin->db->free_result($results);  

else 

    
// set $chat_userlist to a "no one chatting" message if you want, or leave blank.
    
$chat_userlist ''

vB_Template::preRegister('header', array('chat_userlist' => $chat_userlist)); 
Reply With Quote
  #6  
Old 04-06-2012, 08:18 AM
Pianobiz Pianobiz is offline
 
Join Date: Feb 2007
Posts: 2
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the Plugin!!!

How can I show the users on other forum pages besides the start page? And how can I show the chat users in another location of my website - outside of vBulletin?
Reply With Quote
  #7  
Old 04-11-2012, 03:33 AM
kpmedia's Avatar
kpmedia kpmedia is offline
 
Join Date: Jan 2008
Posts: 136
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[s]What needs to be modified to make this work in vB 3.8 ?[/s]

I figured it out. I'll try and make some time to create an actual v3.8.x plugin.
It wasn't too hard, having read the vB4 docs on template variables.

Thanks for making this vB4 plugin available.
Reply With Quote
  #8  
Old 04-13-2012, 02:54 PM
thunderclap82 thunderclap82 is offline
 
Join Date: Nov 2008
Posts: 305
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'd like a widget on the front page to show who is chatting. Any idea how to modify this code to make that work?
Reply With Quote
  #9  
Old 04-16-2012, 06:17 PM
feaelin feaelin is offline
 
Join Date: Dec 2009
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by thunderclap82 View Post
I'd like a widget on the front page to show who is chatting. Any idea how to modify this code to make that work?
That's what the second half ICThawk's original post does for you. Look carefully at the "Displaying the UserNames of Those Online" section. Those two pieces of code will show the usernames of users that are chatting. Just don't forget to turn on the plugin after you create it (I keep doing that and wondering why my plugin doesn't work...
Reply With Quote
  #10  
Old 04-16-2012, 06:27 PM
feaelin feaelin is offline
 
Join Date: Dec 2009
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For what I was working on I wanted the chat window to be "inside", that is, have the usual header, navigation bar, footer, etc. as the rest of the forums, instead of popping up as a window.

This is how I did it (in case someone else needs to do the same thing).

First I made a custom template, named custom_ajaxchat with the following code as the body of the template:

Code:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <head>
    <title>{vb:raw vboptions.bbtitle}</title>
    {vb:raw headinclude}
  </head>
  <body>   
    {vb:raw header}
    {vb:raw navbar}

    <div class="blockbody">
      <div class="blockrow">
        <!-- Custom Code Start Here -->
        <center>
          <iframe src="http://DOMAINNAME.COM/chat/" width="80%" height="640>
          </iframe>
        </center>
        <!-- / Custom Code Ends here -->
      </div>
    </div>
    {vb:raw footer}
  </body>
</html>
Obviously, you'll need to change "DOMAINNAME.COM" to your forum's domain name.

The link in the navbar template I changed from what ICThawk gave us, to this:

Code:
<a class="navtab" href="misc.php?do=page&template=ajaxchat" target="_blank">Chat ({vb:raw num_chatting})</a>
The important parts is the url in href that points to the custom template and removing the 'onclick' event. I also added target="_blank" so that it would open a new tab so the user can continue browsing forums in one tab and chat in another.

You'll still need the Plugin (hooked to global_bootstrap_init_start) that ICThawk provided, I didn't make any changes there.
Reply With Quote
Благодарность от:
dorans
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 02:18 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.09646 seconds
  • Memory Usage 2,355KB
  • 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
  • (2)bbcode_code
  • (3)bbcode_html
  • (4)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
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (3)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete