Hello, I need some help to display the author avatar in last posts and last topics newbb blocks.
The things I did.
1. create a new function on /include/functions.php to get avatar from a given Id.
function getAvatarFromId($userid, $usereal = 0)
{
$userid = intval($userid);
$usereal = intval($usereal);
if ($userid > 0) {
$member_handler = & xoops_gethandler('member');
$user =& $member_handler->getUser($userid);
if (is_object($user)) {
$ts =& MyTextSanitizer::getInstance();
if ($usereal) {
$avatar = $user->getVar('user_avatar');
if ($avatar != '') {
return $ts->htmlSpecialChars($avatar);
} else {
return $ts->htmlSpecialChars($user->getVar('user_avatar'));
}
} else {
return $ts->htmlSpecialChars($user->getVar('user_avatar'));
}
}
}
}
Cloned from getunamefromid with some modifications.
2. in newbb/blocks/newbb_block.php in the function b_newbb_topic_show in this section
$query = 'SELECT'.
' t.topic_id, t.topic_replies, t.forum_id, t.topic_title, t.topic_views, t.topic_subject, t.topic_time, t.topic_poster, t.poster_name,'.
' f.forum_name, f.allow_subject_prefix'.
' FROM ' . $db->prefix('bb_topics') . ' AS t '.
' LEFT JOIN ' . $db->prefix('bb_forums') . ' AS f ON f.forum_id=t.forum_id'.
' WHERE 1=1 ' .
$forum_criteria .
$approve_criteria .
$extra_criteria .
' ORDER BY ' . $order . ' DESC';
$result = $db->query($query, $options[1], 0);
if (!$result) {
newbb_message("newbb block query error: ".$query);
return false;
}
$block['disp_mode'] = $options[3]; // 0 - full view; 1 - compact view; 2 - lite view;
$rows = array();
$author = array();
while ($row = $db->fetchArray($result)) {
$rows[] = $row;
$author[$row["topic_poster"]] = 1;
}
if (count($rows) < 1) return false;
$author_name = newbb_getUnameFromIds(array_keys($author), $newbbConfig['show_realname'], true);
include this line just after the getunamefromids array
$author_avatar = getAvatarFromId(array_keys($author));
so i have an array of the avatars for each id
But i cant pass it to smarty wit this
$topic['avatar'] = $author_avatar[$arr['topic_subject']];
I suppose it is because the $arr is an array created from $rows and this inherit the number of colums created in the $query and $result variables.
Bus as I am not a programmer dont know how to pass it to smarty so I can have a variable like this: <{$topic.avatar}> or what ever..
Any help
Thks