Hello!I have a block code to my SMF forum. The block shows a table with recent topics. The problem is that it shows only name of topic, poster and date. I would like to add topic starter and board name (and maybe (views/read). Can anyone help me with this?
The code:
[code]$num_recent = 25; // HOW MANY RECENT TOPICS TO OUTPUT?
$include_boards = null; // IF ALL BOARDS null | IF SOME BOARDS array( ID1, ID2, ID3)
// code, code, code and some more code bahhh!
global $smcFunc, $scripturl, $context, $settings, $db_prefix, $user_info;
if (is_array($include_boards) || (int) $include_boards === $include_boards)
{
$include_boards = is_array($include_boards) ? $include_boards : array($include_boards);
}
elseif ($include_boards != null)
{
$output_method = $include_boards;
$include_boards = array();
}
$topics_result = $smcFunc[‘db_query’](’’, ’
SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, b.id_board, t.id_last_msg, u.avatar, g.online_color, ’ . ($user_info[‘is_guest’] ? ‘1 AS is_read, 0 AS new_from’ : ’
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from’) . ’
FROM {db_prefix}topics AS t
INNER JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)’ . (!$user_info[‘is_guest’] ? ’
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})’ : ‘’) . ’
WHERE m.approved=1’ . (empty($include_boards) ? ‘’ : ’
AND b.id_board IN ({array_int:include_boards})’) . ’
ORDER BY t.id_last_msg DESC
LIMIT ’ . $num_recent,
array(
‘current_member’ => $user_info[‘id’],
‘include_boards’ => empty($include_boards) ? ‘’ : $include_boards,
)
);
$topics = array();
while ($row_topics = $smcFunc’db_fetch_assoc’)
{
$topics[] = array(
‘topic’ => $row_topics[‘id_topic’],
‘poster’ => ‘’ . $row_topics[‘poster_name’] . ‘’,
‘link’ => ‘’ . $row_topics[‘subject’] . ‘’,
‘href’ => $scripturl . ‘?topic=’ . $row_topics[‘id_topic’] . ‘.msg’ . $row_topics[‘id_last_msg’] . ‘;topicseen#new’,
‘time’ => timeformat($row_topics[‘poster_time’]),
‘new’ => !empty($row_topics[‘is_read’])
);
}
$smcFunc’db_free_result’;
echo ’
Topic | Poster | Time |