vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   How to show active users of the page other than forumhome, forumdisplay, showthread (https://vborg.vbsupport.ru/showthread.php?t=229177)

SpyCam 11-30-2009 01:39 PM

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

kh99 11-30-2009 01:53 PM

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

SpyCam 11-30-2009 04:05 PM

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

kh99 11-30-2009 04:26 PM

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.

SpyCam 11-30-2009 05:34 PM

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.

kh99 11-30-2009 05:48 PM

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.

SpyCam 11-30-2009 06:18 PM

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


All times are GMT. The time now is 02:35 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.01096 seconds
  • Memory Usage 1,738KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (5)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete