Banner image

Chat Technical Help - Server

Problems with the chat

The chat needs a database connection and associated tables etc., If the chat is not working properly, for example you post a message but it doesn't get posted to the chat, Click here

Adding Chat to pages

The chat is a subdirectory of the main biscuits framework release. /home/leonwool/public_html/biscuits-12q/chat
  1. Switch on the chat by adding this to your config.php

    $this->chat = TRUE; This results in a chat sleeper bar on the footer that can be opened up by clicking on it.

    Chat is currently not activated in your configuration.php file applications/englishtap/configuration

  2. The chat requires some HTML. Your outer template can check whether $this->chat is TRUE and load this HTML by
    include CHAT_ROOT . '/html/container.php';
  3. Chat Javascript and CSS If you view the source code for a page containing the chat, you should find:
    1. a javascript file biscuits-chat.js

      Some browsers will open this file if you click on it. This confirms that the script is linked properly to the page.

    2. a CSS file biscuits-chat.css

      This CSS styles the chat - For example the sleeper bar will be positioned at the foot of the page.

    Both the biscuits-chat.js file and the biscuits-chat.css file must be loaded in the page.

    Biscuits engine chat loading code

    if ($this->isInstalled('chat')) {
      $this->addJS(WEB_CHAT_ROOT . '/js/biscuits-chat.js', true);
      $this->addCSS(WEB_CHAT_ROOT . '/css/biscuits-chat.css', true);
      $this->addReadyCode("setChat('" . WEB_CHAT_ROOT . "');");
    }

    Check your page source code now

  4. On page load Setup
    The final component is a setup javascript which you should have in document.ready() called setChat()

Ajax (jQuery) Chat

First of all. The main point to note in the new chat version is that everything is done by ajax. That means that javascript in biscuits-chat.js links through ajax to ajax-chat.php and the class chatMethods.php

Software Components

  • javascript
  • PHP
    • ajax-chat.php
    • chat.php Chat view controlled. Eg: view history link /chat/history
    • chatEngine.php

      Loaded via jQuery ajax-chat.php, this contains all the chat functions such as posting messages and displaying messages. etc.,

  • CSS (Style not functionality)

How the Chat opens

  1. If the chat is installed, it can be started by clicking on the sleeper bar at the base of the page. This starts a js function chatToggle();
  2. This calls JS chatStart();
  3. This uses ajax to run PHP ajax-chat.php
    Since ajax-php is loaded into a visible area to show chat messages, we can debug it by simple echo statements. Just be aware that if the PHP script ajax-chat.php contains errors,it may not be successfully loaded by ajax.
  4. Various application configuration settings are passed via post method into the PHP , such as memberDB class and the DB connection parameters.
  • The chat is switched on by settings $this->modules['chat'] = true in config.php
    This results in the sleeper bar on the footer appearing.
  • Clicking on this sleeper bar will cause the chat to popup or open. The click event runs biscuits-chat.js function chatToggle(); chatToggle() will start the chat, if it's sleeping, by running chatStart();
    chatStart() sets an interval for chatGetMessages('')

Testing Notes

  • The chat display should refresh only when there have been changes in the output of the function chatGetMessages(). Also bare in mind that this function is not called if the scroll bar has been moved from the bottom position. Whenever the virtical scroll bar is moved, the chat is stopped so that the messages can be viewed, edited etc.,
Leon link to chat
Website by Ibiscuits