CakePHP Ajax Chat Demo (v1.2) Question/Comments
Loading...
Notes
- Version 1.2 fixes compatibility with CakePHP 1.2.
- Version 1.1 adds the message to the chat window immediately using javascript.
ReadMe
- You'll need a working version of CakePHP installed. This is running on 1.2.0.6311 beta.
- Download Prototype and put it in /app/webroot/js/
- Download and unzip the contents to app/plugins. The plugin is called "chat", so make sure there is no conflict with any other controllers/plugins
-
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`) );
-
Include the helper in your controller
var $helpers = array('Ajax', 'chat/AjaxChat'); -
Include Prototype in your view if you don't already include it in your layout.
echo $javascript->link('prototype'); -
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');
