Ajax Chat Plugin

This article is also available in the following languages:
By 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.
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
var $helpers = array('Ajax', 'chat/AjaxChat');

5. Include Prototype in your view if you don't already include it in your layout.
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.
echo $ajaxChat->generate('chat1');

Comments

  • Posted 10/19/09 11:13:39 AM
    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 09/02/09 01:25:53 AM
    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 06/10/09 08:39:53 PM
    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 04/22/08 01:16:54 AM
    A .zip of the plugin is available at http://sandbox.siteamonth.com/demo/chat
    The link is dead??
  • Posted 09/25/07 01:04:19 AM
    Great work! I hope someone can add a List Users feature so you can see who's in the chatroom.
  • Posted 08/28/07 10:33:00 AM
    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 04/02/07 12:39:55 AM
    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 03/22/07 01:52:42 PM
    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 11/30/99 12:00:00 AM
    This is very cool :)

Comments are closed for articles over a year old