Welcome to Geeklog, Anonymous Thursday, December 26 2024 @ 02:53 am EST

Geeklog Forums

phpmychat who's chatting block?


Status: offline

scroff

Forum User
Regular Poster
Registered: 02/19/03
Posts: 111
sleepy
I don't really know what I'm doing here, but I almost have this working. It's a block to show who's in phpmychat. I added this code to the end of my lib-custom.php and it does indeed show who's in the chatroom, but the line "Users chatting at this time; scroff" appears above geeklog, not in the block. Like so;

small screen shot

The block is where it's supposed to be and the empty html table shows up in the block, just not that line.

Here's the code I put in lib-custom.php;

Text Formatted Code

// This script is an example of display, in another page of your website,
// the list or number of users connected to the chat

// Lines below must be at the top of your file and completed according
// to your settings

function phpblock_chatters () {

// relative path from this page to your chat directory

require_once( '/home/here/config.php' );
$ChatPath = $_CONF['path_html'] . "AWWchat/chat/";

// HTML link to launch the chat (used by constants below)

$ChatLaunch = "<A HREF='/AWWchat/phpMyChat.php3' TARGET='_self'>chatting</A>";

require_once("${ChatPath}/lib/connected_users.lib.php3");

$ShowPrivate = "1";     // 1 to display users even if they are in a private room,
                                        // 0 else

$DisplayUsers = "1";    // 0 to display only the number of connected users
                        // 1 to display a list of users
define("NB_USERS_IN","users are ".$ChatLaunch." at this time.");        // used if $DisplayUsers = 0
define("USERS_LOGIN","User ".$ChatLaunch." at this time:");                     // used if $DisplayUsers = 1
define("NO_USER","Nobody is ".$ChatLaunch." at this time.");
$display .="<TABLE BORDER=3 CELLPADDING=5>";
$display .="<TR>";
$display .="<TD>";
display_connected($ShowPrivate,$DisplayUsers,($DisplayUsers ? USERS_LOGIN : NB_USERS_IN),NO_USER);
$display .="</TD>";
$display .="</TR>";
$display .="</TABLE>";
return $display;
}

 


I know it probably isn't pretty after I got done with it, but can anyone see why the line "display_connected($ShowPrivate,$DisplayUsers,($DisplayUsers ? USERS_LOGIN : NB_USERS_IN),NO_USER);" would have it's output above geeklog?

Thanks for looking..

edit... gl 1.3.11 php 4.3.10
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
Scruff,

Looks pretty good and I think the problem is with this line
display_connected(...)
You are calling this function which is then probally echo'ing out the line you see. try this $display .= display_connected(..);

That will add it to the $display variable which you are correctly building to return to GL so that it can format it inside the block.
Geeklog components by PortalParts -- www.portalparts.com
 Quote

Status: offline

scroff

Forum User
Regular Poster
Registered: 02/19/03
Posts: 111
cheerful
Hi Blaine,
thanks for the reply! Big Celebration

I did what you suggested, even used $retval .= instead of $display .= throughout, and the same thing happens. After reading more here I'm afraid it's deeper than that though... found this in another thread about phpmychat appearing above GL.


[Quote by: ScurvyDawg]but they both then appeared Above GL rather than in it. Strange hey?


Not at all. That just means that they're doing output directly instead of returning it (as Geeklog would require). More or less the same code as I posted above could be used to work around that. Something like ...
$display .= COM_siteHeader();
ob_start();
// insert code for the chat script here
$display .= ob_get_contents();
ob_end_clean();
$display .= COM_siteFooter();
echo $display;
You get the idea, I'm sure ... Look up ob_start in the PHP manual. bye, Dirk
[/quote]

connected.users.lib.php3, that's called by the code I'm using uses 'echo'... would that have any bearing on this, or do you think I need to get into making the changes to lib.common.php, function COM_siteHeader(), that Dirk suggested here and looking into ob_start?

and I thought this would be so easy! Doh! - that was a mistake
 Quote

Status: offline

scroff

Forum User
Regular Poster
Registered: 02/19/03
Posts: 111
cheerful
After Banging your head for the last two days I finally got this to work. I went into connected.users.lib.php3 and changed all instances of 'echo' to $retval .= and viola! Blah Blah Blah Blah ...
 Quote

All times are EST. The time is now 02:53 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content