CakePHP Ajax Chat Demo (Uses jQuery) Question/Comments
Download the helper
Loading...
ReadMe
- You'll need a working version of CakePHP installed. This is running on 1.2.6.
- Download jQuery and put it in /app/webroot/js/
- Put the chat plugin into app/plugins/chat. The plugin is called "chat", so make sure there is no conflict with any other controllers or 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 '', `name` varchar(20) NOT NULL default '', `message` text NOT NULL, `ip_address` varchar(15) NOT NULL default '', `created` datetime default NULL, PRIMARY KEY (`id`), KEY `KEY_IDX` (`key`) );
-
Include the plugin helper in your controller:
var $helpers = array('chat.ajaxChat');Or just in a particular action:$this->helpers[] = 'chat.ajaxChat';
-
Include jQuery in your view if you don't already include it in your layout.
echo $javascript->link('jquery', false); -
Include the chat js and css in your view.
$javascript->link(array('jquery/jquery', '/chat/js/chat.js'), false); $html->css('/chat/css/chat.css', null, null, false); -
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');
