Back to vBulletin 4.x Add-ons

AJAX Chat Integration
Mod Version: 1.00, by ICThawk

vB Version: 4.1.4 Rating: (4 votes - 4.50 average) Installs: 15
Released: 01 Sep 2011 Last Update: Never Downloads: 0
Not Supported Uses Plugins Re-usable Code Translations  

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)); 

Download

No files for download.


vblts.ru supports vBulletin®, 2022-2024