Ajax Chat Plugin

By Matt Curry (mattc)
A basic Ajax chat plugin.
A .zip of the plugin is available at http://sandbox.siteamonth.com/demo/chat
1. Download Prototype (http://www.prototypejs.org/) and put it in /app/webroot/js/

2. Download and unzip the plugin to app/plugins. The plugin is called "chat", so make sure there is no conflict with any other controllers/plugins

3. Run this sql to create the chats table.
Download code CREATE TABLE  `chats` (
        `id` int(10) unsigned NOT NULL auto_increment,
        `key` varchar(45) NOT NULL default '',
        `handle` varchar(20) NOT NULL default '',
        `text` text NOT NULL,
        `ip_address` varchar(12) NOT NULL default '',
        `created` datetime NOT NULL default '0000-00-00 00:00:00',
        PRIMARY KEY  (`id`),
        KEY `KEY_IDX` (`key`)
      );

4. Include the helper in your controller
Download code var $helpers = array('Ajax', 'chat/AjaxChat');

5. Include Prototype in your view if you don't already include it in your layout.
Download code echo $javascript->link('prototype');

6. Then just add the chat to your view. You can have multiple chats on your site by changing the chat key - "chat1" in this example.
Download code echo $ajaxChat->generate('chat1');

 

Comments 229

CakePHP Team Comments Author Comments
 

Comment

1 Bravo

This is very cool :)
Posted Dec 31, 1969 by Trent
 

Comment

2 Awesome

Matt - this works perfectly. Nice work - I may implement it on lov.li, but I'm a little worried about it overwhelming the server; I'm also looking at Jabber based solutions. kudos to you and the Cake team for making the plugin infrastructure so seamless.
Posted Mar 22, 2007 by PatrickSullivan
 

Comment

3 Too Easy

Another little reason we couldn't be without cake. that was a chat room in less than 5minutes - kudos for the hours that went into this one ;-) shes a wee ripper
Posted Apr 2, 2007 by Paul Webster
 

Comment

4 Saweet

I came here looking for a few code snippits or ideas to get going on a small chat app. And look here, one already built and ready to plug in to my site, wonderful!
Posted Aug 28, 2007 by Kyle Benson
 

Comment

5 List of users

Great work! I hope someone can add a List Users feature so you can see who's in the chatroom.
Posted Sep 25, 2007 by Matthew Roman
 

Bug

6 Download Link dead

A .zip of the plugin is available at http://sandbox.siteamonth.com/demo/chat
The link is dead??
Posted Apr 22, 2008 by Bijay Rungta
 

Comment

7 Download link mirror

Posted May 28, 2008 by wojtek
 

Question

8 What goes where exactly...

Can someone explain what files go where exactly. I am getting:

Missing Helper File - Error: The helper file app/views/helpers/chat/ajax_chat.php can not be found or does not exist.


I include the helper in the app_controller even:

class AppController extends Controller
{
var $helpers = array('Ajax', 'chat/AjaxChat');
}
?>


Also, does this work properly in Cake Version 1.2 or are modifications necessary?
Posted Jun 10, 2009 by Bryan Welfel
 

Comment

9 RE: What goes where exactly...

For 1.2 the syntax should be:

var $helpers = array('Ajax', 'chat.AjaxChat'); 

I doubt this version will work in 1.2. The jQuery version should work though: http://bakery.cakephp.org/articles/view/ajax-chat-plugin-using-jquery
Posted Jun 11, 2009 by Matt Curry
 

Bug

10 Missing Controller

after installing plugins i get following

Error: UpdateController could not be found.

can any one explain why this error occured?
i m using cakePHP 1.2.8284
Posted Sep 2, 2009 by SatyaM
 

Comment

11 chat + auth

I'm using a pretty basic Auth + ACL implementation.
Whenever chat loads, something must be going wrong w/ my user session, because I'm immediately logged out.

ideas?
Posted Oct 19, 2009 by aaron b