Is it possible to initialize a chat room in a CMS page, without using iframe?

74 views
Skip to first unread message

donshakespeare

unread,
Oct 19, 2015, 10:16:39 AM10/19/15
to AJAX-chat
Okay the only way I have been able to get chat is via the mycms.com/chat/index.php, and then by using iframe to call it within another page.

Is there a way to initialize chat in say, mycms.com/index.php?id=34

Thanks

ClubSyNXTremeTV

unread,
Oct 19, 2015, 3:50:42 PM10/19/15
to ajax...@googlegroups.com
Are you familiar with using ajax with jquery and loading everything in a <div id="id goes here"></div> container?

example:

<script type="text/javascript" src="path to jquery">

<script type="text/javascript">

var $j = jQuery.noConflict();

$j(document).ready($){

 function(){
 $
.ajax({
 type
: "GET",
 url
: "url path to your script/chat (and you can use strings)",
 success
: function(data){
 chat
= data;

$
("#load_chat").html(chat);

         
}

     
});

   
};

 
});

</script>

Then in your body you call for it to load in the <div id="load_chat"></div> container

donshakespeare

unread,
Oct 19, 2015, 6:33:14 PM10/19/15
to ajax...@googlegroups.com
That won't work unless you hard-code the chat script tags.
No JS will load in the page, and the CSS will all be screwed

Fabian Wilson

unread,
Oct 19, 2015, 8:20:40 PM10/19/15
to donshakespeare, AJAX-chat

You could try a shoutbox.

On Oct 19, 2015 5:33 PM, "donshakespeare" <tryshak...@gmail.com> wrote:
That won't work unless you allow script is made.
No JS will load in the page, and the CSS will all be screwed

--
You received this message because you are subscribed to the Google Groups "AJAX-chat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ajax-chat+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

donshakespeare

unread,
Oct 19, 2015, 9:49:52 PM10/19/15
to AJAX-chat, tryshak...@gmail.com
Good idea, just that I am not sure the shoutbox has full functionality.
I have even forgotten how to use the shoutbox...
...back to the drawing board

donshakespeare

unread,
Oct 20, 2015, 12:45:22 AM10/20/15
to AJAX-chat, tryshak...@gmail.com
I found how to implement shoutbox http://www.simplemachines.org/community/index.php?topic=380417.0
Works flawlessly, that's how the main chat should be implemented...only that it gets its base url really messed up if you try to clone the original index.php and put the new file in a different folder

ClubSyNXTremeTV

unread,
Oct 20, 2015, 4:38:28 AM10/20/15
to AJAX-chat
The method I mentioned I actually used one before loading the chat perfectly if you know what you are doing.

But whatever, as long as you get it working.

Fabian Wilson

unread,
Oct 20, 2015, 9:27:39 AM10/20/15
to ClubSyNXTremeTV, AJAX-chat
I was able to add functionality to my shoutbox by adding a the divs from Loggedin.html to the shoutbox.html files.

On Tue, Oct 20, 2015 at 3:38 AM, ClubSyNXTremeTV <s...@clubsyn-x-treme.net> wrote:
The method I mentioned I actually used one before loading the chat perfectly if you know what you are doing.

But whatever, as long as you get it working.

--

donshakespeare

unread,
Oct 20, 2015, 10:38:16 PM10/20/15
to ajax...@googlegroups.com
For anybody wondering, especially in a CMS, use the exact same code in the /chat/index.php
Now any file in any folder level can have the full chat displayed, no AJAX, no shoutbox, just pure full sweetness!
Make the AJAX_CHAT_PATH absolute

AND

In your loggedIn.html and loggedOut.html templates add an absolute base href.
If your site uses www, you must add it or else you will have origin problems
<?php
/*
 * @package AJAX_Chat
 * @author Sebastian Tschan
 * @author Philip Nicolcev
 * @copyright (c) Sebastian Tschan
 * @license Modified MIT License
 */

// Suppress errors:
error_reporting(0);

// Path to the chat directory:
define('AJAX_CHAT_PATH', '/absolute/path/public_html/mysite/assets/chat/');

// Include custom libraries and initialization code:
require(AJAX_CHAT_PATH.'lib/custom.php');

// Include Class libraries:
require(AJAX_CHAT_PATH.'lib/classes.php');

// Initialize the chat:
$ajaxChat = new CustomAJAXChat();

For perfect ease, put that code in a snippet, and dump it in any file you want
In MODx do:[[!chat]]

donshakespeare

unread,
Oct 20, 2015, 11:08:44 PM10/20/15
to AJAX-chat
For MODxers, use this snippet [[!chat]] MODX_ASSETS_PATH is already defined for you
/*
 * @package AJAX_Chat
 * @author Sebastian Tschan
 * @author Philip Nicolcev
 * @copyright (c) Sebastian Tschan
 * @license Modified MIT License
 */

// Suppress errors:
error_reporting(0);

// Path to the chat directory:
define('AJAX_CHAT_PATH', MODX_ASSETS_PATH.'components/chat/');
Reply all
Reply to author
Forward
0 new messages