I was wondering how I could add a specifc chat (not chat room) embedded in a block.
Essentially I am trying to have a chat in the bottom of my Main Page..sort of a support.I have seen such in other websites but am not sure how to get this going

CommentFileSizeAuthor
#4 screenshot.jpg64.68 KBafrazer

Comments

yngens’s picture

I am also looking for a way to include a chat window to another page, node, view or front page.

avatar123’s picture

Is there a way to this, or should I assume it is not possible.Please advice

JonGirard-1’s picture

Same with myself, I'm also looking for a way to do just this.

Jon.

afrazer’s picture

StatusFileSize
new64.68 KB

I did this successfully, with the following steps:

Create a new block.
Provide the block's body as

<? print chatroom_chat(2);?>

where 2 is the id number of the chat you want to open there.

Be sure you set the input type as php.

If you want the user list displayed with it, you can use the included Chat Room Online List block that comes with the module and should be listed among your blocks when the module is installed.
But it won't understand which chat you are in, the quickest way to fix it if you just have 1 chat room and don't care about coding "form" is to just replace the code starting around line 887 in chatroom.module with

/**
 * Get a list of on-line users in a given chat.
 */
function theme_chatroom_block_chat_online_list() {
//  if (!preg_match('/^chatrooms\/chat\/(\d+)/', $_GET['q'], $matches)) {
//    return array(false, false);
//  }
  $chat_id = 2;//$matches[1];

(where 2 is the id number of the chat you want).

This will have the side effect of making the title of all your pages include "live chat", and showing the chatroom in your breadcrumbs - if you don't like that, comment out the following lines in chatroom.module, starting around 1147:

//        $bc = drupal_get_breadcrumb();
//       $bc[] = l($chat->chatroom_name, "node/$chat->nid");
//        drupal_set_breadcrumb($bc);
//        drupal_set_title(check_plain($chat->chatname));

DON'T archive this chat, or you'll screw everything up real bad. If you want to archive it, get rid of all the blocks first.

You could do this in a more thorough way, but this was enough for my needs. It should really be a block that the module furnishes.

Works for me, so far at least.

-Aharon Frazer

JonGirard-1’s picture

Very nice.. thank you so much for posting this..

Jon.

keanu007’s picture

I tried the
<? print chatroom_chat(2);?>

but this does not work for me Any ideas ?

yamill’s picture

it worked for me. thanks!

Keanu007 you need to enable to php code in the filter text for it to work.

darclex’s picture

followed the directions and it totally works i'm on drupal 5.10

afrazer totally rules for sharing this and making it work for the rest of us

check it out at

yourboyvic.com

hankpalan.com’s picture

I get Fatal error: Call to undefined function chatroom_chat() in /includes/common.inc(1648) : eval()'d code on line 1
when I try the code:

<? print chatroom_chat(2);?>

I'm using the php filter.

hankpalan.com’s picture

Nvmind, I was using the 6.x version. I'm using the insert node module instead of printing it in a block.

rschwab’s picture

I'm trying to do this as well, and in the block none of the chat features show up. Here's what I've done:
- Install both modules
- Set up a new input format with only the Node Insert filter used.
- Set up a block using the new input format and with a content of "[node:59]" (59 is the nid of my chatroom)
- Place the block in a region

What shows is:

Test chat
Submitted by myusername on Wed, 07/21/2010 - 12:33
Last message at Wed, 07/21/2010 - 13:49: update by myusername. Total messages: 5.

Basic chat description

* Add new comment

No chat messages, no user list, no message submission form. I checked the chatroom content type to see if I needed to manually add those fields in the Node insert statement, but no fields are listed.

Has anyone used Node Insert to successfully get a chatroom in a block using 6.x? If so, mind sharing how you accomplished this?

- Ryan

truyenle’s picture

What is the function in Drupal 6, I mean:
D5: chatroom_chat($nid);

D6:? I don't see chatroom_chat() in D6?

Please help

Truyenle

marta_yo’s picture

Version: 5.x-1.9 » 6.x-2.12

I'm too interested in show a chat in a block in drupal 6, please...

truyenle’s picture

well, I got it work by this code

<?php
$node = node_load($nid);
print node_view($node, FALSE, TRUE, FALSE);
?>

Where $nid is the node id of chat content.

dmuth’s picture

Status: Active » Patch (to be ported)

Hi folks,

I expanded on the previously posted idea here, and wrote a full-blown PHP script to display a chat in a block, and filter out author and taxonomy information. Here it is:

http://gist.github.com/546688

Permission is granted to use this code in the project and/or documentation as you see fit.

If anyone wants to see this code in action, I'm running on the site http://www.pa-furry.org/. You'll need to be a valid user, but the site supports creating an account from an OpenID (Or Twitter/Facebook/etc.). I run the site, so feel free to create an account there to see the chat system.

-- Doug

greenreaper’s picture

Thanks, Doug! Here's a few additions I found useful; I figured others might as well:

//
// Remove newlines (required by some below)
//
$html = preg_replace('|\n|', '', $html);

//
// Remove bottom border/padding/margin (example of style change)
//
$regexp = "<div id=\"node-$nid\"";
$html = str_replace($regexp, "<div id=\"node-$nid\" style=\"margin-bottom:0;border-bottom:0;padding-bottom:0\"", $html);

//
// Adjust column and row count
// 
$regexp = 'cols="60" rows="5"';
$html = str_replace($regexp, 'cols="35" rows="3"', $html);

//
// Remove user list
//
$regexp = "|<div id=\"chatroom-user-list-wrapper\">.*?</div>|";
$html = preg_replace($regexp, "", $html);

//
// Remove CKEditor note
//
$regexp = "|<div class=\"textarea-identifier description\">.*?</div>|";
$html = preg_replace($regexp, "", $html);

//
// Remove chatroom buttons for anon users
// 
global $user;
if ($user->uid == 0) {
  $regexp = "|<div id=\"chatroom-chat-buttons\"><form.*?</form></div>|";
  $html = preg_replace($regexp, "", $html);
}

glitz’s picture

i would like to do this. where would I place the above code, Within the block body and changing the input filter? Or, Would I need to file this file in another location?

glitz’s picture

nm got it THANKS! :)

glitz’s picture

i was able to get the block working, but i would like to disable the actual chat page view so it is in-accessible (as an entire page).
any way to do this without deleting the block?

glitz’s picture

also, I was wondering if there was anyway to clear the chat history in the window after a certain amount of time. So if no one is using the chat room overnight, you wont see the chat history from the night before...

I thought I had this set up in the chatroom global settings but it is not the case for the block view

(this also is the same for the time stamp format)

glitz’s picture

any suggestions?

StudioARE’s picture

Tried a combo of the two latest scripts, but it makes the breadcrumb think it's on the chat for every page.

Like.. "Home » Forums » Chat"

Anyone know how to fix that?