PDA

View Full Version : vbphrase works in forum&blog navbar but not CMS navbar...?


firebrand4
12-31-2009, 09:38 PM
Hello. I use Blueimp's AJAX Chat (https://blueimp.net/ajax/) and a modified navbar to display the number of people in the chatroom. As you can see in the attached images, the count displays fine when I am in Forums or Blogs, but when I am in the CMS it doesn't display (showing just "Chat []" instead of "Chat [1]"). Can anyone help me figure out why?

Here's how I have it set up:

includes/functions.php
function render_navbar_template($navbits)
{
global $vbulletin, $vbphrase;
$vbphrase['chatcount'] = count(getChatOnlineUserIDs());
[...] Then in my style template for 'navbar':
<li class="selected"><a class="navtab" href="http://[site].com/chat/" target="_blank">Chat [{vb:rawphrase chatcount}]</a>
[...]And I don't think it matters, but here are the chat functions I define in functions.php immediately preceding the render_navbar_template function above:

function getChatInterface() {
static $ajaxChat;
// Path to the chat directory:
if (!defined('AJAX_CHAT_PATH')) {
if (empty($_SERVER['SCRIPT_FILENAME'])) {
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'].$_SERVER['SCRIPT_URL'];
}
define('AJAX_CHAT_PATH', realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/chat').'/');
}


// Include Class libraries:
require_once(AJAX_CHAT_PATH.'lib/classes.php');

// Initialize the chat interface:
$ajaxChat = new CustomAJAXChatInterface();


return $ajaxChat;
}

function getChatOnlineUsers() {
$chatInterface = getChatInterface();
if($chatInterface) {
// Clean out any users who didn't log out properly by calling removeInactive()
// Not necessary but a good idea. You can take out this line if you want.
$chatInterface->removeInactive();
// Now get the online users:

return $chatInterface->getOnlineUsers();
}
else {
return array();
}
}

function getChatOnlineUserIDs() {
return ($chatInterface = getChatInterface()) ? $chatInterface->getOnlineUserIDs() : array();
}
So I'm stumped on how to get this to display properly in the CMS navbar. How would it render differently between the CMS and the Forum/Blogs? Any help would be much appreciated!