Coder Social home page Coder Social logo

chat's Introduction

/*
 * CakePHP Ajax Chat Plugin (using jQuery);
 * Copyright (c) 2008 Matt Curry
 * www.PseudoCoder.com
 * http://github.com/mcurry/cakephp/tree/master/plugins/chat
 * http://sandbox2.pseudocoder.com/demo/chat
 *
 * @author      Matt Curry <[email protected]>
 * @license     MIT
 *
 */

/* Description */
A basic Ajax chat plugin for CakePHP using jQuery

/* Instructions */
   1. You'll need a working version of CakePHP installed. This is running on 1.2.0.7692 RC3.
   2. Download jQuery and put it in /app/webroot/js/
   3. Put chat plugin into app/plugins/chat. The plugin is called "chat", so make sure there is no conflict with any other controllers or plugins
   4. 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`)
      );

   5. Include the plugin helper in your controller:
      var $helpers = array('chat.ajaxChat');

      Or just in a particular action:
      $this->helpers[] = 'chat.ajaxChat';

   6. Include jQuery in your view if you don't already include it in your layout.
      echo $javascript->link('jquery', false);

   7. 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);
            

   8. 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');

chat's People

Contributors

mcurry avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.