This is exactly what I want to do (actually just need to add the users avatar to each comment).
I've copied the above but it doesn't work - tried to figure out why but can't
Here's my code
Template:
Quote:
<table width="100%" cellspacing="1" class="outer">
<{foreach item=comment from=$block.comments}>
<tr class="neweven">
<td align="left"><img src="<{$comment.poster.avatar}>" /><{$comment.title}> Posted by <{$comment.poster}>
</td>
</tr>
<{/foreach}>
</table>
Systems Block:
Quote:
function b_system_comments_show($options)
{
$block = array();
include_once XOOPS_ROOT_PATH.'/include/comment_constants.php';
$comment_handler =& xoops_gethandler('comment');
$criteria = new CriteriaCompo(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
$criteria->setLimit(intval($options[0]));
$criteria->setSort('com_created');
$criteria->setOrder('DESC');
$comments = $comment_handler->getObjects($criteria, true);
$member_handler =& xoops_gethandler('member');
$module_handler =& xoops_gethandler('module');
$modules = $module_handler->getObjects(new Criteria('hascomments', 1), true);
$comment_config = array();
foreach (array_keys($comments) as $i) {
$mid = $comments[$i]->getVar('com_modid');
$com['module'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/">'.$modules[$mid]->getVar('name').'</a>';
if (!isset($comment_config[$mid])) {
$comment_config[$mid] = $modules[$mid]->getInfo('comments');
}
$com['id'] = $i;
$com['title'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/'.$comment_config[$mid]['pageName'].'?'.$comment_config[$mid]['itemName'].'='.$comments[$i]->getVar('com_itemid').'&com_id='.$i.'&com_rootid='.$comments[$i]->getVar('com_rootid').'&'.htmlspecialchars($comments[$i]->getVar('com_exparams')).'#comment'.$i.'">'.$comments[$i]->getVar('com_title').'</a>';
$com['text'] = $comments[$i]->getVar('com_text');
$com['icon'] = htmlspecialchars( $comments[$i]->getVar('com_icon'), ENT_QUOTES );
$com['icon'] = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif';
$com['time'] = formatTimestamp($comments[$i]->getVar('com_created'),'m');
if ($comments[$i]->getVar('com_uid') > 0) {
$com['poster'] = array();
$poster =& $member_handler->getUser($comments[$i]->getVar('com_uid'));
if (is_object($poster)) {
$com['poster']['link'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$comments[$i]->getVar('com_uid').'">'.$poster->getVar('uname').'</a>';
$com['poster']['id'] = $comments[$i]->getVar('com_uid');
$com['poster']['uname'] = $poster->getVar('uname');
$com['poster']['avatar'] = '<img src="'.XOOPS_URL.'/uploads/'.$poster->getVar('user_avatar').'" />';
} else {
$com['poster']['link'] = $GLOBALS['xoopsConfig']['anonymous'];
}
} else {
$com['poster']['link'] = $GLOBALS['xoopsConfig']['anonymous'];
}
$block['comments'][] =& $com;
unset($com);
}
return $block;
}
Thanks for any help