Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 11-30-2009, 01:39 PM
SpyCam SpyCam is offline
 
Join Date: Mar 2006
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to show active users of the page other than forumhome, forumdisplay, showthread

Hello,
i'm trying to get a page to show $activeusers content on a page.
Actually it's a Cyb ChatBox for Vb 3.8.4 but it is not supported so i thought it should be simple for me to do that on my own but i failed.

What i tried is i copied the part of code from my SHOWTHREAD template to the chat template. This is the code:

Code:
<if condition="$show['activeusers']">
  <!-- currently active users -->
   <div class="div-header">
    <div class="div-header-right" style="float:right"></div>
    <div class="div-header-left"></div>
    <phrase 1="$totalonline" 2="$numberregistered" 3="$numberguest">$vbphrase[users_viewing_this_thread_x_y_z]</phrase>
   </div>
  <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
    <tr>
      <td class="alt1" colspan="2"><span class="smallfont">$activeusers</span></td>
    </tr>
  </table>
  <!-- end currently active users -->
</if>
  <if condition="$show['activeusers']">$template_hook[showthread_after_activeusers]<br />
  </if>
But it didn't work. I'm affraid it's because the page showing the chat actually looks like this in browser's address bar: misc.php?do=cchatbox

Do you have any idea how to show what forum members are currently active on that page? Because on a chat, it's lame to have no list of active users...

Thanks in advance
Reply With Quote
  #2  
Old 11-30-2009, 01:53 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The problem is that the template gets it's information from variables which must be set in the php code for the page you're displaying. If you look at showthread.php and search for each occurance of 'activeusers' you'll see that there is quite a bit of code involved in building up the $activeusers variable before it's used in the template (although some of it might be doing other things as well).
Reply With Quote
  #3  
Old 11-30-2009, 04:05 PM
SpyCam SpyCam is offline
 
Join Date: Mar 2006
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not a PHP programmer, but i usually don't have big problems to make small php alterations, at least for vbulleting templates, i inspected the source of the showthread template but didn't really find any other "hooks" of code needed for $activeusers to be displayed.

Could you give me some hints of what to look for in it?

Thanks in advance
Reply With Quote
  #4  
Old 11-30-2009, 04:26 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, if you search in showthread.php for:

PHP Code:
if ($vbulletin->userinfo['userid']) // fakes the user being in this thread 

I think this is start of the part that adds the current user. A little below that is:

PHP Code:
eval('$activeusers = "' fetch_template('forumdisplay_loggedinuser') . '";'); 
So that starts creating the value of $activeusers by adding the current user (which I guess is why you always show up first on the list).

Then below that is a loop which starts:

PHP Code:
while ($loggedin $db->fetch_array($threadusers)) 

That looks like the part that adds all the other active users, one at a time. A little below that is:

PHP Code:
eval('$activeusers .= "' fetch_template('forumdisplay_loggedinuser') . '";'); 

The ".=" appends to the string, so that line adds one more user.

Since you are using misc.php whihc doesn't have this code, $activeusers (which appears in the part of the template you borrowed from SHOWTHREAD) will be blank.

So, you could try copying the block of code between these comments:

PHP Code:
// *********************************************************************************
// Get users browsing this thread
   
.
   .
   .
// *********************************************************************************
// get similar threads 
But I don't know, it might not turn out to be that easy. The thing I'm wondering about is that the comment says "Get users browsing this thread". I haven't studied the code, but if that comment is accurate, it could mean that it won't do exactly what you want.

ETA: ...also, there may be important things that happen in the code before the block I mentioned above, in which case you may need to copy more that just that block.
Reply With Quote
  #5  
Old 11-30-2009, 05:34 PM
SpyCam SpyCam is offline
 
Join Date: Mar 2006
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you. I didn't think at all about that i should edit PHP file. I tried the things you suggested but it didn't work, so now i'm trying different things to find a working solution.
Reply With Quote
  #6  
Old 11-30-2009, 05:48 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, I was kind of afraid that it wouldn't work. I don't know anything about that mod, so I don't know if the code for "users viewing a thread" has anything to do with the code that would be needed for "users currently chatting".

BTW, as far as editing php files, if you have to add code it's better to find a hook and insert the code as plugin, if possible. So if you figure out what code to add to create your list, you might be able to find a hook someplace in misc.php (or in some included file like global.php or init.php) and make it a plugin.
Reply With Quote
  #7  
Old 11-30-2009, 06:18 PM
SpyCam SpyCam is offline
 
Join Date: Mar 2006
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, after like 10 tries, i gave up. I don't have brains of a programmer to find the answer
Reply With Quote
Reply

Thread Tools
Display Modes

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 10:34 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04258 seconds
  • Memory Usage 2,215KB
  • Queries Executed 13 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete