General > Tips and tricks

Quick&dirty - webIM and JOOMLA 1.5

(1/1)

freepokero:
NOTICE: Only tested with Joomla 1.5.10 ! May not work with joomla versions <1.5 ! For this versions, look at the mambo guide -> http://mibew.org/forums/index.php?topic=137.0

What this modification does: Including the webIM button into a joomla website, and giving the username and the emailadress to the webIM software


So i included openwebIM fast and dirty in joomla, and for those of you who want to do that too, here is how i did it.

However: This is not a joomla component or anything, i just include the button and give the username of the logged in joomla user to the chat.

First, i made a "chatinclude.php" in the webim/ directory including this code:


ATTENTION: Look at the red highlighted pice of code in here ("+'&name='+escape(username)+'&email='+escape(email)") this must be added to the button code you got from webIM! however, in this php file MY button code which i got from webIM is included, feel free to delete it (from "<!-- Botton Code" until the end). but make sure you add the red marked text afterwards!
Also note that i changed the width and height of the button in this example!


--- Code: ---<?PHP

$user =& JFactory::getUser();
$username = $user->username;
$email = $user->email;
switch($username) {
case '':
$username = 'Guest';
break;
case ' ';
$username = 'Guest';
break;
}
?>
<script>
var username = "<?php echo $username; ?>"
var email = "<?php echo $email; ?>"
</script>
<!-- Button code. Attention!!! If you are editing the code, make sure to -->

<!-- webim button --><br><a href="/webim/client.php?locale=en" target="_blank" onclick="if(navigator.userAgent.toLowerCase().indexOf('opera') != -1 &amp;&amp; window.event.preventDefault) window.event.preventDefault();this.newWindow = window.open('/webim/client.php?locale=en&&amp;url='+escape(document.location.href)+'&amp;referrer='+escape(document.referrer)+'&name='+escape(username)+'&email='+escape(email), 'webim', 'toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1');this.newWindow.focus();this.newWindow.opener=window;return false;"><img src="/webim/button.php?image=webim&amp;lang=en" border="0" width="102" height="34" alt=""/></a><!-- / webim button -->

--- End code ---

This is the last part of the code (the Button code) so i can highlight the thing you need to add ;-)

<!-- webim button --><br><a href="/webim/client.php?locale=en" target="_blank" onclick="if(navigator.userAgent.toLowerCase().indexOf('opera') != -1 &amp;&amp; window.event.preventDefault) window.event.preventDefault();this.newWindow = window.open('/webim/client.php?locale=en&&amp;url='+escape(document.location.href)+'&amp;referrer='+escape(document.referrer)+'&name='+escape(username)+'&email='+escape(email), 'webim', 'toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1');this.newWindow.focus();this.newWindow.opener=window;return false;"><img src="/webim/button.php?image=webim&amp;lang=en" border="0" width="102" height="34" alt=""/></a><!-- / webim button -->

Safe this file as chatinclude.php and upload it to your /webim/ directory.

Then go to the joomla template index.php you use. open the index.php file and insert following at the position you want the button to appear:


--- Code: ---<?php include_once(JPATH_ROOT.'/webim/chatinclude.php'); ?>
--- End code ---

As i said, it's not the way you should add things to mambo. It's quick and dirty.

domnick0:
I have added it to my joomla site but didn't hack the code just added a custom html module and inserted the button code works fine for me and if you want to really incorporate it into the core trying getting the easy creator component

EasyCreator is a developer tool.
It trys to speed up the developing process of custom components, modules, plugin and templates.
You can create a 'frame' for your extension and an installable zip package with just a few 'clicks'.

http://easy-joomla.org

Navigation

[0] Message Index

Go to full version