JoomlaComment and JomSocial integration
by Daniel Dimitrov on October 14, 2009
Many of you have requested the possibility to show jomsocial avatar in comments. Now I finally found the time to install jomSocial and to write the necessary code for this. You will find the option to show jomsocial avatar in the next version of joomlacomment, but for those who are not afraid to make changes to comment.class.php and want to test the code you are welcome to do so.
The first thing you will need to do is to open comment.class.php and go around line 2262 (this is the post_htmlCode function): Find this code:if ($this->_avatar) {
if(JString::strpos($this->_avatar,"gallery/")===false) {
$path = JURI::base()."/images/comprofiler/tn$this->_avatar";
} else {
$path = JURI::base()."/images/comprofiler/$this->_avatar";
}
$html = str_replace('{avatar_picture}', $this->profileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_user_id), $html);
} else if ($this->_gravatar) {
$gravatar_email = $this->_item['email'];
$default = JURI::base().'components/com_comment/assets/images/nophoto.jpg';
$size = 60;
// Prepare the gravatar image
$path = "http://www.gravatar.com/avatar.php?gravatar_id=".md5(strtolower($gravatar_email)).
"&default=".urlencode($default)."&size=".$size;
$html = str_replace('{avatar_picture}', $this->profileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_user_id), $html);
}
and change it to this:
//if ($this->_avatar) {
// if(JString::strpos($this->_avatar,"gallery/")===false) {
// $path = JURI::base()."/images/comprofiler/tn$this->_avatar";
// } else {
//
// $path = JURI::base()."/images/comprofiler/$this->_avatar";
// }
//
// $html = str_replace('{avatar_picture}', $this->profileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_user_id), $html);
// } else if ($this->_gravatar) {
// $gravatar_email = $this->_item['email'];
// $default = JURI::base().'components/com_comment/assets/images/nophoto.jpg';
// $size = 60;
// // Prepare the gravatar image
// $path = "http://www.gravatar.com/avatar.php?gravatar_id=".md5(strtolower($gravatar_email)).
// "&default=".urlencode($default)."&size=".$size;
//
// $html = str_replace('{avatar_picture}', $this->profileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_user_id), $html);
// }
Now after the above code add this:
$path = JURI::root() . $this->jomSocialAvatar($this->_item['userid']);
$html = str_replace('{avatar_picture}', $this->jomSocialProfileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_item['userid']), $html);
After the closing bracet "{" of the post_htmlCode function add those 2 functions:
function jomSocialProfileLink($s, $id) {
if ($id) {
$link = JRoute::_('index.php?option=com_community&view=profile&userid='.$id);
return "<a href='$link'>".$s."</a>";
} else {
return $s;
}
}
function jomSocialAvatar ($id) {
if($id) {
$database =& JFactory::getDBO();
$query = 'SELECT thumb FROM #__community_users WHERE userid = ' . $id;
$database->setQuery($query);
$result = $database->loadObject();
return $result->thumb;
} else {
return 'components/com_community/assets/default_thumb.jpg';
}
}
This should be everything! Don't forget to enable the use of avatar in the backend. Please report back! I've tested this code on a system with only one account - the administrator one :) I will be happy to hear that it works as well on a community website :)
-
2009-10-14 16:27:41 | petunia
-
2009-10-20 15:56:37 | SKDA - SEO for joomlacomment + comprofiler

http://compojoom.com/component/comprofiler/userprofile/petunia
I see this link display. How to make it?
Thanks!
-
2009-10-20 19:13:10 | Daniel Dimitrov
-
2009-10-22 20:45:35 | Alejandro - did not work

Do i need to have CB installed? Maybe you can post the file for download.
A.
-
2009-10-22 21:36:11 | Alejandro - Yes it works fine... sorry about last post

Just Great THNX!!!!!!!!!!
-
2009-11-02 05:46:45 | Alejandro - error whne using micosoft explorer

Daniel. I change code to use jomsocial avatar but get an error while commenting using micosoft explorer... please try the site so you get the error message. Still the message does get posted, but error is confusing users.
A.
-
2009-11-06 15:35:07 | Daniel Dimitrov
-
2010-02-04 16:39:14 | Vladimir
-
2010-02-05 09:15:27 | Antony

Great Joomla! Extension.It's The Best Comment Component that I've ever used.I installed it in my Joomla! site and it works like a charm.Easy to configure with a lot of features to get it working just like you want it.
-
2010-06-15 07:32:31 | Steve
-
2010-06-16 05:45:57 | Daniel Dimitrov
Testimonials
Best support, fast upgrades
I don't really leave as many reviews as I should, but the support provided by Daniel is on par with the other leading extensions support groups.
I bought the component and installed it, and had questions about some customization (support for JomSocial + Avatars). I posted my questions on the forum, and within a couple of hours I had a very helpful response. I used to use the free !JoomlaComment extension, but when I saw that they went "pro" I definitely trusted their work on my site....
Professional coded..
Easy and quick install, a lot of features (antispam protection, quoting previous comments, reply to comments, rss and e-mail subscription...). I've tested some other comment modules for joomla and compojoom is one of the best because of the features and I've found no bug at all during testing...
Read all testimonials >>
Newsletter
Our Blog
Hacking competition is over (1)
02.09.2010, 01:32:
I'm sad to announce that our hacking competition is over. However I'm really happy to say that the latest compojoomComment 4.1.7 couldn't be cracked : ...
Read more
- 31 August 2010:
- Hotspots 1.0 beta1 released (2)
- 16 August 2010:
- CB profiles and user comments (9)
- 15 August 2010:
- Hotspots project status (5)




hi daniel, i have no test your code yet, but i want to share this that i have found on another community, is a hack to show jomsocial avatar in comments and also you can choose from backend wich avatar you want to show, jomsocial, CB, gravatar or none.
This hack was made by jsharim, i have test it and works for me, maybe this could help you with integration.
http://www.4shared.com/file/140851433/6ef67a74/joomlacomment_js_cb.html