Ajax Chat Plugin

By Matt Curry aka "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 Wed, Dec 31st 1969, 18:00 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 Thu, Mar 22nd 2007, 13:52 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 Mon, Apr 2nd 2007, 00:39 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 Tue, Aug 28th 2007, 10:33 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 Tue, Sep 25th 2007, 01:04 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 Tue, Apr 22nd 2008, 01:16 by Bijay Rungta

Login to Submit a Comment