Page 1 of 1

Comments + Avatar

Posted: Wed Jan 18, 2012 11:35 pm
by brownstone4
Hi,

I need some php coding help and I am using jomsocial + joomla. I am trying to get the avatar to show for the right user that made the comment. At the moment when a user comments it displays the users name and generates the link with their name to their correct profile. I have also got it so that the avatar links to the correct profile of the user that made the comment.

The avatar image is where I have the problem because it displays the image of the logged in user and not the user that made the comment. How do I connect the two?

At the top of the appropriate .php file I have added the following to get the jomsocial info.

Code: Select all

$jspath = JPATH_BASE.DS.'components'.DS.'com_community';
include_once($jspath.DS.'libraries'.DS.'core.php');
require_once( JPATH_ROOT . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'userpoints.php');
$user =& CFactory::getUser();
$avatar = $user->getThumbAvatar();
$name = $user->getDisplayName();
Further down where the comment portion is in the same file I have

Code: Select all

<div class="comment comment_<? echo $k; ?>">
<?php $userprofile_link= JRoute::_( 'index.php?option=com_community&view=profile&userid='. $comment->user_id); ?>
<div class="comment_name"><a href="<? echo $userprofile_link; ?>"><? echo $comment->username; ?><img src="<?php echo $avatar; ?>" title="<?php echo $name ?>" alt="<?php echo $name ?>" /></a></div>
<div class="date"><? echo JHTML::_('date', $comment->date, JText::_('DATE_FORMAT_LC2')); ?></div>
<div class="comment_text"><? echo $comment->comment; ?></div>
</div>
New to php and any help would be appreciated.

Thx.

Re: Comments + Avatar

Posted: Thu Jan 19, 2012 3:32 am
by theserve
There is likely to be some data relating to the post as opposed to the user. You will get the avatar from that data. You might be better of directing this query over to jomsocial as its product related as opposed to just php related.