The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
HTML Code in Widget
I have AJAX Chat installed on my site, and there is code someone shared that allows the number of users using chat, as well as listing the names, that appear in the What's Going On section. (See here.) It involves a plugin and template change and, once done, works. I'd like to use this code in a Widget on the front page but no matter how I alter the code it doesn't work in the widget. The code for the templates is:
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 --> |
#2
|
|||
|
|||
You probably need to preRegister the variables to the template you're using. In the code on that page there are calls to vB_Template:reRegister() for FORUMHOME and navbar, but you need to change it (or add calls) to register to your template.
|
#3
|
|||
|
|||
Quote:
Code:
<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> PHP Code:
PHP Code:
The widget now appears, but only says "Users in Chat". Looking at the code it should show the number of users (i.e. 2 Users in Chat) as well as list their names, but it doesn't. Thoughts? |
#4
|
|||
|
|||
Instead of a static html widget, try creating a php direct execution widget and use code like this:
Code:
$templater = vB_Template::create('ajax_chat_widget'); $output = $templater->render(); Also, those instructions you linked to show another plugin using hook global_bootstrap_init_start that calculates the number chatting, so you'd need to add another preRegister call there as well. When configuring the php direct execution widget, there's a field for cache time. If you set it to 0 it will execute every time someone accesses a page that shows the widget, but if you set it to 1 (the minimum allowed), then the widget will only update once per minute. You can choose which one works for you. Setting it to 0 probably isn't a problem since you aren't doing much in your widget code, and the database queries in the plugin are being done each time anyway. |
#5
|
|||
|
|||
Appreciate the help. I enabled the other plug-in and added the preRegister for ajax_chat_widget in that plugin, and now the number of people chatting shows but the list of users is still empty. I even attempted to add
PHP Code:
|
#6
|
|||
|
|||
Hmm...it might have to do with the order that things happen. I'm away from my test system so I can't try it right now. You left the preRegister in for $chat_userlist, right?
Did you set the cache time to 0? You'd want to do that while working on it even if you've decided to set it to 1 minute, otherwise it's easy to get confused when things don't change right away. |
#7
|
|||
|
|||
Quote:
PHP Code:
Quote:
--------------- Added [DATE]1381161136[/DATE] at [TIME]1381161136[/TIME] --------------- I fixed the problem. I ended up changing the hook from global_start to global_bootstrap_init_start. Not sure if that will mess anything else up, but it got the job done. Thanks again for all your help, kh99. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|